- Home /
How to get AI to open closed door in NavMesh Pathfinding
Hi!
We are making a first person stealth prototype with a 3D environment. We have a guard AI with working pathfinding using Unitys NavMesh system. Also we have a door prefab that the player can open and close with the 'E' key.
However we can't think of a way for the guard to figure out that he can get through a closed door by opening it. Is there a way to add exceptions or events into the NavMesh pathfinding that trigger when a guard wants to go through a closed door or is there some other clever way to solve this problem?
Did you try using a trigger or something when the enemy approaches the door which opens the door and then the enemy can get in!!
You could just have it so the door isn't actually a navmesh obstacle so the navmesh goes through the door even if it is closed. Then to stop the AI just walking through a closed door they could raycast before moving to check for doors. Or the door could have a large trigger area around it so if the AI is within range and moving towards it it sends message to say it is closed. Or you could test if the path corner it is trying to navigate to next is inside a room with a closed door.
Either way it would then tell the AI to cease movement, perform the door opening animation and continue moving after.
Yeah i was suggesting the "having a large trigger on the door" which opens the door when the AI is near by. Does it not work or you want something different ?? (it seems to be the easiest way that i can think of)