Reputation: 1198
I'm working on a platform game at the moment. I have a problem with AI jump movement. Path is already found with complete walk and jump points. However jump action is problematic.
on example image: AI should perform a jump at the red points and land on the next green point.
Do you know perform these curved jumps?
Upvotes: 1
Views: 1588
Reputation: 1201
As huntsfromshadow said you can look at making a parabola for which the formula btw is
y = -x * x
You can also tweak the formula a bit with a few constants... best way to test this is using wolfram alpha http://www.wolframalpha.com
But I'll suggest different solution. Add a simple "jump simulation" which will look more realistic. - add velocity to your entity - in the moment of jump add large upwards impulse by modifying the velocity - each frame add downwards velocity which suppose to be gravity - each frame modify the position by adding velocity to it
Don't aim for the first green point accurately. Make the jump to feel right and if the creature overshoot some of the green points just make it walk towards the next one.
Upvotes: 2
Reputation: 1085
I would suggest looking at algebra and map the movement as a parabola.
Try different modifiers to the basic parabola equation of y = x (or y = -x as you are doing the upside down parabola).
Upvotes: 1