- Home /
Navmesh navigation in stealth game
Refer to the image.
I'm trying to make your typical distract enemy by throwing stuff mechanic. Currently as it stands, I'm making the enemy go to where the object lands during their "investigation" phase.
Now, the problem is what if the player were to throw the object on a high or inaccessible place like a shelf or vending machine? I'm afraid this might just cause the enemy to just hang around and crowd around the bottom trying to reach something unreachable
Answer by RX187 · Aug 28, 2018 at 07:13 PM
Well in theory if the object, the vending machine or shelf is set as a navmesh obstacle it should make the ground navmesh recalculate and make that position not walkable so the enemy would go there and just stare at the vending machine. What you could do is have a timer on the distract mechanic and once that is done the enemy AI would resume patrol or the default position it had before and you can very easily do this with a coroutine.
https://docs.unity3d.com/ScriptReference/Coroutine.html
IEnumerator WaitAndPrint()
{
// suspend execution for 5 seconds
yield return new WaitForSeconds(5);
// the code for your resume patrol
}