Hi, I’m trying to create AI for my game using behavior trees.
Right now the AI just walks around randomly.
I have an AI task that find a random location with GetRandomPointInNavigableRadius (GetRandomReachablePointInRadius gives me the same results, what is the difference between the two?), then moves there using the basic “Move To” task.
This works great when the new location is in the same room.
But sometime to reach the new random location, the move to task will create a path that doesn’t seem to take into account the size of my AI character (its capsule). Sometime the AI wants to go right through a wall, under a doorway or an archway that is too small or between two objects that are too close to each other. The AI will get stuck after a few seconds and the Move To fails.
I understand why the Move To fails, the path is blocked. But not why the GetRandomPoint is able to return an impossible location. I use the boolean “Return value” output parameter to validate the new location and I try to find a new one if it failed. I haven’t set anything to the “Nav Data” and “Filter Class” pins, should I put something in there? This node only finds a location on the navmesh and does not validate if it’s actually reachable by my character. Should I then validate if a path exists? Will “Get Navigation System” -> “Find Path to Location Synchronously” and check if the output path “Is Valid”? But then the “Move To” won’t use this path, it will probably recalculate a new one, and this one might fail.
The capsule component is big enough to surround the whole mesh. I’ve also tried to manually set the “Nav Agent Radius/Height” and untick the “Update Nav Agent with Owners Collision” for the CharacterMovementComponent with no result.
Here it’s trying to go through the wall.
Thank you for any help.