Synchronise an object position based on second object angle

Discussion and feedback on Construct 2

Post » Thu Apr 17, 2014 6:17 pm

Hello,

What i wish to do is take Object A angle and set Object B position relative to the angle of Object A at a certain distance (lets say 200pixels) so if the Object A is taking another direction, the Object B must stay at 200 pixels in front of Object A at 200 pixels of position of Object A. The idea is if i am shooting object A that object b could serve as a detector in front of Object A. (This is not a line of sight only a simple detector.)

Any ideas what i can use for this ?

Thanks for your help! Greatly appreciated. :-)
B
16
S
5
G
1
Posts: 190
Reputation: 2,489

Post » Thu Apr 17, 2014 6:35 pm

Rushino wrote:Hello,

What i wish to do is take Object A angle and set Object B position relative to the angle of Object A at a certain distance (lets say 200pixels) so if the Object A is taking another direction, the Object B must stay at 200 pixels in front of Object A at 200 pixels of position of Object A. The idea is if i am shooting object A that object b could serve as a detector in front of Object A. (This is not a line of sight only a simple detector.)

Any ideas what i can use for this ?

Thanks for your help! Greatly appreciated. :-)


you could use the Pin behavior on ObjectB, and pin "position and angle" relative to Object A

Or you could set ObjectB position to :

X: 200*cos(ObjectA.Angle)+ObjectA.X
Y: 200*sin(ObjectA.Angle)+ObjectA.Y

Or even set an object point in the image editor 200 pixels forward the center of ObjectA, and set the position of ObjectB to it.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Fri Apr 18, 2014 1:56 pm

Aphrodite wrote:
Rushino wrote:Hello,

What i wish to do is take Object A angle and set Object B position relative to the angle of Object A at a certain distance (lets say 200pixels) so if the Object A is taking another direction, the Object B must stay at 200 pixels in front of Object A at 200 pixels of position of Object A. The idea is if i am shooting object A that object b could serve as a detector in front of Object A. (This is not a line of sight only a simple detector.)

Any ideas what i can use for this ?

Thanks for your help! Greatly appreciated. :-)


you could use the Pin behavior on ObjectB, and pin "position and angle" relative to Object A

Or you could set ObjectB position to :

X: 200*cos(ObjectA.Angle)+ObjectA.X
Y: 200*sin(ObjectA.Angle)+ObjectA.Y

Or even set an object point in the image editor 200 pixels forward the center of ObjectA, and set the position of ObjectB to it.


Work fine! Thanks a lots for your help.
B
16
S
5
G
1
Posts: 190
Reputation: 2,489


Return to Construct 2 General

Who is online

Users browsing this forum: oozkaya and 7 guests