Changing Navigation Path Dynamically

In my game, the enemy bots have basic logic, such as patrolling area, follwing a player, finding the closest cover and moving to it, and all these things depend on what is happening in the current situation, if the bot sees an enemy, or if it doesn’t, or it hears one and guesses a general location of the enemy. The problem I am having is that when I calculate a new path, I clear the old one, and all this logic happens every frame so the path is destroyed then created and repeat. Therefore, in situations, the bot does not move at all do to this. I made a delay that calls the logic every few game ticks but it slows the reaction of the bot big time. Does anyone have any suggestions how to recalculate the path with out it fighting against clearing the path?

1 Like

MotionPath are more meant to be static really or as you said, not cleared and rebuild on every frame.
What you talk about sounds like basic AI and path finding, you should have a look at this http://hub.jmonkeyengine.org/forum/topic/ai-plugin-now-with-navmesh-pathfinding/#

@nehon said: MotionPath are more meant to be static really or as you said, not cleared and rebuild on every frame. What you talk about sounds like basic AI and path finding, you should have a look at this http://hub.jmonkeyengine.org/forum/topic/ai-plugin-now-with-navmesh-pathfinding/#
Ah yes, I have been on that thread numberous times were I learned how to use the pathfinding. The problem I am seeing is that the pathfinding in that and monkeyZone and those examples, is that it calculates a path and goes there, and once it is there, It calculates another path. If I am checking conditions periodically to determine what path to take, it seems a bit complicated in terms of paths overwriting each other. Say that bot is at a coverpoint, It still checks all the other possibilites, and finds the same one its at, as long as a stay still, and computes a path there even when it doesnt need to. Is there a better way you would go about accomplishing this sort of task? Computing all these paths really takes a hit on my CPU so If I could compute it where I only need it.