Parabolic movement between 2 points

1 favourites
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • I have a fixed startpoint A at x,y and a dynamic destination at B x,y, by selection of mouse/touch.

    I am looking for an approach other then physics to make an object follow a parabolic leaps from a to b in a isometric like scenarion.

    It does not have to be precise, or a perfect arch, its for a bit of eye candy so it needs to be light and perhaaps lerped or something.

    I'd like to do this without plugins.

    Right now I use a combination of a fixed 270 ddegree impule combined with an angluard impulse with some distance math. It works semi, though, its not perfect, far from.

    Another approach I used was with a bullet and some gravity, but I cant make out the formula needed to have it target switch to another B point.

    the best so far was with the physics ...but its also in accurate, if you have a better suggestion then the following:

    targetx,y is start point, countries x,y is point b

    <img src="https://dl.dropboxusercontent.com/u/7134196/physics_arch.png" border="0" />

    If you see room for improvement or have a better approach, I'd be gratefull :)

    In short: how do I make an arch like effect between 2 points on an x,y grid.

  • If it's just for eye-candy I would create the arc with the custom movement behaviour.

  • If it's just for eye-candy I would create the arc with the custom movement behaviour.

    I got as far as to adding it earlier ... checking the options .. testing a few, .. and having some similair issues as to the bullet with grav.

    I can worj out 1 nice arch with some trial and error, but when I aim for another location, say the opposite side, ... then it goes awry.

    Suggestions as to approach with custom movement?

  • If you can move an object from one point to another then all that's left is to move up and down as well.

    With this formula as a base for the parabolic motion:

    1-4*(x-0.5)^2

    Here's a capx:

    https://www.dropbox.com/s/cpzg482vpmatb ... .capx?dl=1

    /examples21/leaper.capx

  • If you can move an object from one point to another then all that's left is to move up and down as well.

    With this formula as a base for the parabolic motion:

    1-4*(x-0.5)^2

    Here's a capx:

    https://dl.dropboxusercontent.com/u/5426011/examples21/leaper.capx

    Sweeeeet :D

    Thanks a lot R0J0hound !!!

  • If you can move an object from one point to another then all that's left is to move up and down as well.

    With this formula as a base for the parabolic motion:

    1-4*(x-0.5)^2

    Here's a capx:

    https://www.dropbox.com/s/cpzg482vpmatb ... .capx?dl=1

    /examples21/leaper.capx

    Thank you ROJOhound for sharing your knowledge. This formula and its application in the Capx is priceless. Truly grateful. In the past I have spent over a hundred hours looking for a parabola formula while I was learning to use "scratch" and later "appInventor". I found a more complicated version of what you show here and was dreading finding a way to implement it in Construct. Your approach is concise and flawless. Your post not only helps me save time (which is precious) but has me smiling at the possibilities and ease of using parabolic motion under many more scenarios and playing with the parameters or variables that you provided.

  • R0J0hound - this is super cool! Such an elegant solution to a complex problem, and something I've wrestled with multiple times, usually ending up with a bunch of fudges and magic numbers to get it approximating to what I need. Adding my vote of thanks for sharing.

    Out of interest, how could you adapt this so that upon the sprite reaching (xend,yend) it continues along the parabola?

  • 99Instances2Go

    Sorry, I'm stuck on r244 for the time being so can't check that out. I'll check it once 245 goes stable.

  • mekonbekon

    Remove the t<1 condition and change the "set t" expression to self.t+dt/leaptime.

  • R0J0hound Brilliant! Works like a charm. I owe you a bagful of scooby snacks

  • Thanks R0J0hound, using your example, I manage to fix the X position of the object to another object, base on the distance and speed of this last object.

    I calculated the distance between the points and divided by its speed --> var=(dist(start.x,start.y,end.x,end.y)/sprite.speed

    Then I put it into your 't' variable --> t=min(t+timedelta/var,1)

    I just post that in case of anyone want a leap distance/time instead of using a variable for the speed you use in the lerp.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Resurrecting this post in hopes for a solution.

    Super grateful to R0J0hound for the original work.

    Does anyone know if there is a way to make the projectile's angle face the direction it's moving?

    Sorry if there is an easy solution but the math for this is pretty over my head.

    Thanks for any help

  • [Sprite] Set Angle Toward (sprite.xend, sprite.yend)

  • [Sprite] Set Angle Toward (sprite.xend, sprite.yend)

    This will end up with the sprite always pointing towards the initial touch point.

    Instead, add two instance variables to the sprite, xLast and yLast, and whilst the sprite is moving use

    [Sprite] Set angle to angle(self.xLast,self.yLast,self.X,self.Y)

    [Sprite] Set xLast to self.X

    [Sprite] Set yLast to self.Y

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