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 Image
B
161
S
48
G
90
Posts: 7,348
Reputation: 66,751

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
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

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
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

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 Image
B
161
S
48
G
90
Posts: 7,348
Reputation: 66,751

Previous

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests