- Home /
Question by
nice_shot · Aug 16, 2018 at 12:14 PM ·
ainavigation
NavMesh run away in enclosed space
I'm writing a survival game in which NPCs are trying to escape zombies and other hostile enemies. I'm using NavMeshAgent for both the zombie and the NPC. I got the zombie chasing the character easily but running away is a bit more difficult. Most of the answers I've seen regarding fleeing just make the character move away from whatever's chasing him. Something like:
Vector3 runTo = transform.position + ((transform.position - Zombie.transform.position) * multiplier);
(Suggested in https://answers.unity.com/questions/868003/navmesh-flee-ai-flee-from-player.html)
The problem is that my game mostly takes place in small enclosed spaces so this method leeds to the NPC running towards the wall. I'm looking for a solution that can make the NPC change direction, get away and find a safe spot.
Any suggestions?
Comment