- Home /
Duplicate Question
Enemy freezes in NavMesh and starts attacking? [Duplicate]
Duplicate of This
Hello. I've been trying to learn about NavMesh for a while now in hopes to bring life to a Maze which is Randomly Generated. As we know that NavMesh can't be built at run-time, so I added a plane and baked it as the floor, and set the walls as a NavMeshObstacle Objects, which turn out rather nice. Screenshot http://imgur.com/Z8HAysh
However, the enemies have an odd behavior as title indicates, they look for a random position after some time and so, they will walk/float onto the new position, or that's what I expected at least.
-They Walk under normal circumstances, but they sometimes walk back, or get stuck, seemingly rotating around and walk for a bit until they find a new position-
They also have a Shooting controller, which is only meant to be activated if the player is close enough, and visible/in front of the enemy. But it gets activated either way.
Code's Here http://pastebin.com/DYmfSq3N
I honestly can't find the issue, but reducing the NavMesh radius from 1.9 to .5 seems to helped a bit, as they now walk more instead of being stuck. But other than that I really don't know. Also, there's another script where I experimented witth the NavMeshAgent before appling it to the Enemy Script. TestNav.cs This one seems to be working just fine, no freezes nor anything.
PS: Should I seperate these into seperate components?