Calculate curve between two points...

0 favourites
  • 9 posts
From the Asset Store
Footsteps SFX Two contains 450 sounds of steps and jumps on different surfaces.
  • I am looking for an equation to calculate the parabolic curve between two points...or just a nice gradual curve that works would suffice!

    Efforts so far have been far from perfect...

    I am not using a behavior so just the maths will do...


  • With just two points all you exactly have defined is a line. You'll need three points to define a curve.

    The standard formula for a parabola is the following:


    Plugging in the x,y positions for the three points into the formula will give you three equations where the only unknowns are a,b and c. Then it's just a matter of using standard algebra to solve for the unknowns.

    If that doesn't help, do you have more info about what you're trying to do?

    In general the process is called curve fitting:

  • rojohound Thanks for the response,Ah the third point is probably what I'm missing...

    I am trying to calculate the trajectory of a missile/artillery

    I have the projectiles origin x,and the target x,the "ceiling" of the curve may have to be squashed down to keep it in the constraints of the layout,but if that is not possible I could probably work around that..

    Your equation may help, however I am unsure how to calculate that third point...

    Maths and algebra are not my strong point...

    Again thanks...

  • There have actually been a few threads about projectile tracking in the past, try using the search tool.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There is very little on this, that I can find, most involve bullet or physics behaviors ...

    But thanks for help...

  • This topic is relevant:

    But you're right it does use the physics behavior so here is a capx the behavior replaced by four actions:

    It has the math worked out so the initial launch angle points somewhere above the target and from that a speed is calculated so the target is reached. It's a sightly different approach than what I outlined before. The initial angle can be anywhere in the range of the angle to the target and straight up.

  • rojohound Thanks for taking the time to help, I really appreciate it...

    This pretty much covers exactly what I wanted...

    One question though,and apologies as I failed to mention this in my initial post, how would I get the object to fix it's angle to the blue line, like a javelin?

    Again many thanks for this...

  • While there are ways to calculate the slope on any point on a parabola I find a simpler method is to save the old position of the objects and set the angle from the old to current position. The event would look like this:

    +every tick

    set angle to angle(self.old_x, self.old_y, self.x, self.y)

    set old_x to self.x

    set old_y to self.y

    This method has the added benefit that it can be used with any motion.

  • Yup, that makes sense, I was expecting more complex!, but if it works, great, again thanks...

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