Moving Object from A to B

For questions about using Classic.

Post » Sun Nov 29, 2009 12:37 am

Thought about a lerp solution to this. Its pretty much the same as Mipey's.
[code:26kevabm]square: Value 'var' Less than 1
System: Every square.Value('speed')*timedelta milliseconds
> squareSet position to lerp(square.X, point.X, square.Value('var')), lerp(square.Y, point.Y, square.Value('var'))
> squareAdd 0.01 to 'var'[/code:26kevabm]

Done with two private variables, speed, and the percentage called var.


[url:26kevabm]http://dl.dropbox.com/u/666516/lerpnoslow.cap[/url:26kevabm]

Edit: For a smother transition make var smaller, and adjust speed accordingly.
Image ImageImage
B
165
S
49
G
148
Posts: 8,048
Reputation: 97,088

Post » Sun Nov 29, 2009 2:02 am

why don't you just move at angle with cos and sin, I don't see the need for lerp if all you want to do is move towards a point at a set speed.
B
33
S
5
G
8
Posts: 1,210
Reputation: 7,046

Post » Sun Nov 29, 2009 3:37 am

Ok, I'm confused now. Is the red line what you want to achieve?

If so, qarp might be your best choice (a thread shows how to use it best, if I remember right)
Image
B
24
S
8
G
10
Posts: 1,821
Reputation: 8,279

Post » Sun Nov 29, 2009 3:03 pm

Added two more variables original x, and original y. The first example actually would slow down since it was using current x,y.
Image ImageImage
B
165
S
49
G
148
Posts: 8,048
Reputation: 97,088

Previous

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests