Hi guys. I've been working on something for a while and I'd appreciate some help if anyone is interested.
What I want to do is have a character 'jump' from a point, to another point, while moving through a point in between. I want this to be visualized as a parabola. I also want it to appear like a 'natural' jump.
I've done everything but making the jump look natural. What I'm doing so far is calculating two parabolas through code, one on the left side of the central point and one on the right, then adding both of their points to a Curve2D. I add the Curve2D as the curve property of a Path2D, slap a PathFollow2D on there and iterate over it using its unit_offset property. This causes the character to move along the parabola at a constant rate. So far so good.
But here's where I'm stuck. I want to move across this curve as if I'm jumping, meaning I want the character to slow down at the top of the curve and speed up again as he comes back down. I can't figure out a way to do this. Currently I'm just tweening from 0 to 1 and setting the PathFollow2D's
unit_offset property to that. The problem is that if I interpolate using say,
EASE_IN_OUT, the slowing takes place exactly at the x center of the curve. Which is a big problem for curves like the second one above, because the exact center is not the highest point.
What I've tried:
- Literally split the arc in two (treating it as 2 curves rather than combining each half-parabola into one). This allows me to calculate the proper speed and do
EASE_OUT on one side and
EASE_IN on the other. This doesn't work though because when I interpolate the character through them there's a 'catch' at the central point, and there seems to be no way to get rid of that (removing the central point from one of the curves so it isn't 'duplicated' does the opposite of help)
I also haven't included any code because there's a decent amount. If you think it would help you to see it outside the conceptual realm, just let me know. I have separate scripts for the standard arc and the split arc I tried so let me know which you'd like to see.
Please feel free to give me any questions along the lines of "Why are you doing it that way, my guy?" This is just me working and I tend to overcomplicate things. As far as I can tell this is the only way to accomplish this.
Thank you again.