# How Can I Move Object Along Curve

Get help using Construct 2

### » Tue Sep 08, 2015 4:39 pm

Hey,

I can't find any information on how to move an object along a curve from point a to point be.. This could be a half circle, or any kind of curve. I can use Lerp or LightTween. Please don't just say it's all math. I know that much, lol. I'm trying to find the math to solve this problem. I understand a random curve with bullet, adding to angle of motion and subtracting from angle of motion, but what if you want to curve to a specific location?

JB.
B
7
S
2
Posts: 92
Reputation: 663

### » Tue Sep 08, 2015 5:27 pm

You have a few options.

One could be to use catmull-rom splines to do the curve:
http://www.scirra.com/forum/follow-path ... page1.html

Use this behavior:
viewtopic.php?t=67833&start=0

Also could use the qarp() and cupic() expressions:
B
97
S
36
G
131
Posts: 5,511
Reputation: 83,460

### » Tue Sep 08, 2015 8:40 pm

Awesome thanks for the update, will definitely check these out. I've got a lot of movement issues solved, and line picking. Even though I don't understand all the equations I know what they do and saved them away. My math is a bit bad, but I've been studying. Problem is the math level for great games is considerably high... For mathematicians they're like oh, it's not that bad, trig, and linear algebra... but for someone with weak math skills, and just starting to learn trig at all, they're nowhere near that level of understanding in numbers, and matrices.
B
7
S
2
Posts: 92
Reputation: 663

### » Wed Sep 09, 2015 8:17 pm

Hey,

Those are really tough examples. I think my best option would be to start learning qarp right now. The only problem is I'm not real sure of the parameters, and how to make it work. I've got a little capx set up with two points and a sprite. The problem is, I don't think it's working right. Just trying to qarp from current location to the two points.. Could you maybe explain the parameters of qarp to me?

Also if you could you could maybe take a look at this?

https://www.dropbox.com/s/ayig74ctzlvl1 ... .capx?dl=0

If not, a better ideas of the parameters would be a great help.

Thanks,
Jeremy.
B
7
S
2
Posts: 92
Reputation: 663

### » Wed Sep 09, 2015 8:27 pm

You need three points and a sprite. The first and last point are the endpoints and the middle point controls the curve. In the most simple example you would setup the events like this:

global number t=0

every tick:
--- set t to min(1, t+1*dt)
--- sprite: set x to qarp(p1.x,p2.x,p3.x,t)
--- sprite: set y to qarp(p1.y,p2.y,p3.y,t)

the "1" in t+1*dt is the number of seconds it takes to move.
The min() expression is used to make it stop at the end. otherwise it would keep going.
B
97
S
36
G
131
Posts: 5,511
Reputation: 83,460

### » Wed Sep 09, 2015 9:27 pm

Cool, got results now, but it doesn't necessarily go to the middle point eh? Kind of sucks. Was hoping to do kind of a way point kind of thing, but spline plugin is giving me issues. I get internal errors like _points is not defined.
B
7
S
2
Posts: 92
Reputation: 663