Character is too big to navigate through door way, but still tries.

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.

TrollIsTooBig.png
Here it’s trying to go through the wall.

Thank you for any help.

I have managed to fix my problem, but I’m not sure if it’s the right way.

I added a nav agent in the project setting > Navigation System. The 1st one with default values. The 2nd one with the size of the capsule of my big AI monster.

Then I enabled both agents on the nav mesh bounds volume.
NavMeshProps.png

There are now 2 RecastNavMesh in my World Outliner, one for each agent.

The default one for human sized AI agent. Select the corresponding RecastNavMesh and toggle the “Enable Drawing” property.
DefaultRecastNavMesh.png

The “Big Agent” recast nav mesh for larger AI agent. Select the corresponding RecastNavMesh and toggle the “Enable Drawing” property.
BigAgentRecastNavMesh.png

The character some how magically select which kind of agent it should be.

For fun I scaled the troll actor so it would be small enough to go through the doorway and it worked! Then in the level blueprint I slowly scaled it back up with a timeline to see what would happen. At 1st it worked, but then it got physically too big to go through the doorway and it still tried to go on the other side => it’s stuck on the “Default” agent, and didn’t update when it got big enough. There might be a property or a function to call somewhere, if someone knows about it, that would be nice! But I don’t think I’ll dynamically scale AI characters during their life span in my game, so it’s not a problem.

2 Likes

i would like to hear if that is actually how it is supposed to be done from an official/experienced dev bump

Me too :cool:

What do you mean, you’ve been given the perfect answer, with pictures!

It’s rare to get a response from a dev, take what you can get…

1 Like

The difference is whether the point is navigable (has navmesh coverage) or reachable (can be navigated to) from the AI’s current coordinates. In a case where a navmesh is generated with no walkable path to it (on top of a box or pillar that is higher than max step height, for example) GetRandomPointInNavigableRadius() will return this “impossible” destination and your unit will attempt to move there. GetRandomReachablePointInRadius() will only return points that can be reached on the navmesh and excludes “island” mesh locations.
However, like GetRandomPointInNavigableRadius(), GetRandomReachablePointInRadius() also won’t check to see if the path is wide enough for the unit to actually navigate through based on collision geometry, as you have noted and solved for yourself above.