How do I set a third object at the midpoint of two others?

Get help using Construct 2

Post » Thu Mar 10, 2016 12:42 am

Not sure how much more I can explain besides the title. I'm sure it's simple to accomplish but I'm not sure what I'd use.
B
8
S
1
Posts: 60
Reputation: 574

Post » Thu Mar 10, 2016 12:48 am

lerp(a,b,x) should do it.

spriteC set X to lerp(spriteA.X, spriteB.X, 0.5)

That should place spriteC exactly in the middle between spriteA and spriteB on X axis.
ImageImageImageImage
B
158
S
66
G
43
Posts: 2,603
Reputation: 35,868

Post » Thu Mar 10, 2016 1:02 am

That basically works! Though I just thought of something: what if the second object's target was the part of the bounding box the first object was closest to, rather than targeting the second object's origin?
B
8
S
1
Posts: 60
Reputation: 574

Post » Thu Mar 10, 2016 1:12 am

lerp(a,b,x) a or b can be anything - x will always be a "way from a to b".
"bounding box the first object was closest to" should be fine too. It all depends what you want to do and then adjust your math to make it work ;)
ImageImageImageImage
B
158
S
66
G
43
Posts: 2,603
Reputation: 35,868

Post » Thu Mar 10, 2016 1:15 am

I guess by bounding box I meant collision box, I think. Not sure of the name. Actually I kind of figured out a weird way to go about what I wanted to do. Thanks for the help though, it pointed me in the right direction!
B
8
S
1
Posts: 60
Reputation: 574


Return to How do I....?

Who is online

Users browsing this forum: AnD4D, newt and 22 guests