- Home /
Make an agent finds his way out
Hi everyone,
I'm asking myself how to make an agent to wander in a building (let's stay with one floor for the moment) and search his way with the corridor and room he will encounter. I saw the NavMesh but it's too determinist for the agent calculates the correct path directly.
I had the idea to make my agent navigate point by point on the NavMesh, storing visited ones, and when he encounter a junction, select a random way and store the point where is the junction so he can come to it back if his choice wasn't good.
The problem is how will i select the points ? For example : If enter a room with only one exit a the opposite, the agent don't have to wander eternally in the room but instead go straight to the corridor.
Is there a way or a trick to approach this behavior ?
Thanks in advance !
The trick is navmeshs, lol. Seriously though, what they provide are "hints" to the navigation algorithm. In your example, this would be done by using the navmesh to layout a path directly between the room's entrance and exit: no choices, just a single path. Obviously, you don't HAVE to use a navmesh, but it sounds like you do want to at least provide the hint that the number of "junctions" in that room is 0.
Your answer
![](https://koobas.hobune.stream/wayback/20220612141035im_/https://answers.unity.com/themes/thub/images/avi.jpg)