How to get POS between 2 sprites at 3rd's Ypos?

Get help using Construct 2

Post » Fri Feb 01, 2013 7:58 pm

So I've been messing with that fake 3d engine and I've hit a math snag.

I need to find the position between 2 sprites at a third sprites y position.

say you have a gird:

| | | | | | | | | |

And I Want a sprite to follow an imaginary line between two of these lines:

| | |o| | | | | | |

How do I calculate the pos between the 2 line sprites at the object sprites y pos?

I've tried the "distance(spriteline1.x,spriteobj3.y,spriteline2.x,spriteobj3.y)" but I'm not even sure if thats what I need here or if that is even correct.

Thanks for the help in advance, I've been stuck on this one for two days...

Chris
B
45
S
12
G
7
Posts: 339
Reputation: 7,899

Post » Fri Feb 01, 2013 8:07 pm

Did you try lerp(a,b,x)?

lerp(sprite1.X, Sprite2.X, 0.5) shoud put your sprite between

file.capx
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Fri Feb 01, 2013 8:51 pm

Thanks shinkan, that was part of the problem. But that is getting the position between of the first and second sprites origin point which is dead centre of the screen.

The two gridline sprites get further apart as they reach the bottom of the screen. The 3rd sprite travels towards the bottom of the screen.

I need to know what the position is between the first two sprites according to the third sprites Y location.

That position would then become the third sprites X position. Causing it to travel on an angle according to the two grid sprites.
B
45
S
12
G
7
Posts: 339
Reputation: 7,899

Post » Sat Feb 02, 2013 3:43 am

Never mind - ditched this for "move at angle" instead. Now the sprites do what I want but I forgot c2 rotates the sprites with the angle...ARGH!!! Invisible place holder sprites are going to cut into the speed :( Fingers crossed.
B
45
S
12
G
7
Posts: 339
Reputation: 7,899


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 34 guests