Smoothing out AI pathing

Started by
4 comments, last by Timkin 18 years, 4 months ago
I'm currently developing a 2D sidescroller. My goal is to have relatively intelligent foes populate this game, that are capable of at least finding their way around the level without looking too stupid. I recently got an A* (or A*-ish, at any rate) algorithim working. I've been for the most part satisfied with how the AIs are finding their way around my test level, except for one thing. Whenever they try to reach a node above them, the crazed jumping they do is insane. Basically the moment the area they're trying to reach is above them, they jump, resulting in bunny-hopping and poorly timed jumps that can even accidently drop them down to another level! What I want to do is have them figure out when to time their jumping and their acceleration so that they'll pass through the node they're trying to reach in a more convincing way than they currently are. What ways can I go about this?
Advertisement
Well, you could presumably make the holes unwalkable (so it doesn't path into them) and make jumping more costly than moving on the ground (so it only chooses it if nessesary).
Thats not the problem. I WANT them to reach the upper nodes, but they're doing it in a stupid manner.

The AI have the ability to move left, right, and jump (when on solid ground). They also have relatively limited air control. What I currently am having them do in order to reach a specific corrdinate is a method so simplified that its sickening: if its off to either side, move towards it. If its above the AI, jump, regardless of current velocity and distance to targetted position.

What I WANT them to do is make more intelligent looking movements. Specifically, I want them to stop bunny hopping and choose their jumping time (as well as the position and velocity they leave the ground) more intelligently.
Well, if your agents miss their jumps, the problem is very clear: In your A* implementation, you add nodes to the path that arent really accessible from the top node. No smoothing is gonna help you there: you have to come up with a correct accessibility function that check if the node is *really* accessible from the current node with the specified action and current velocity.

Good luck!

They aren't so much missing their jump as simply jumping too soon or too late. Its because they constantly bunnyhop whenever they want to get somewhere above them, even though they should probably time the jump. I just don't know how to do that properly.
The solution seems fairly simple... you need to constrain the agents trajectory at the point of hitting the node, so that when it executes the jumping action, the result is a transition to the higher level. Personally, I'd fit a spline for the velocity curve, constrained by the spatial nodes resulting from the pathing search (which are discrete solutions of the integral of the velocity spline). This will give you the information you need for your agent to move in the correct directions and jump so as to achieve the correct transition.

Cheers,

Timkin

This topic is closed to new replies.

Advertisement