# Moving Object from A to B

### » 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'))

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

### » 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

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

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

Previous