Possible bug in Wander logic

Pedro

Member
I found what seems to be a bug in the wander logic. If I place another character (or object) in the path of a wandering character the character will be blocked by that object and will be running in place pushing up against it but will not try to go around it or turn around and will only continue moving once the object is out of its way. I'm guessing this has to do with it using a basic navmeshagent but I'd imagine a behavior tree system should be intelligent enough to go around objects that are not baked into the navmesh.
 
The wander task is responsible for telling the agent where to wander to, but it's up to the navigation system to get that character there. In this case it sounds like you can use the NavMeshObstacle component.
 
Just to update. I've noticed some other unexpected and hard to reproduce behavior during wander. Sometimes a character will just start walking in circles (spinning as if the turning key is pressed) and only "snap out of it" if it is nudged either by another wandering character or by some object.

I'm wondering if maybe some "fail-safe" behavior should be added that if it is supposed to move and gets stuck it tries turning and walking in another direction for a few steps to get out of whatever blockage it finds itself in and not get stuck in an infinite loop at some location.

Edit: They'll walk in circles even when there is no obstruction and the navmesh seems normal in that location. I've noticed this by launching many simultaneous characters all using the same script and I've only seen it happen to one every so often which makes it hard to reproduce.
 
Last edited:
If the character walks in circles near the destination try increasing the stopping distance on the NavMeshAgent. You could also increase the arrived distance on the actual wander task.

Does the Behavior Tree only use NavMesh for all its movement?
The built in tasks do, but there are integrations with the A* Pathfinding Project.
 
Top