How Can I Move Object Along Curve

0 favourites
  • 6 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • 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?

    Thanks for your time,

    JB.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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:

    about-the-new-interpolations_p787879?#p787879

  • 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.

  • 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.

  • 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)