- Home /
NavMeshAgent collision not working with player
Hello there,
I'm working on a project right now.
Here's the thing since Unity 3.5 : My enemies have a NavMeshAgent. My player doesn't, he has a Character Motor, Character Controller and Platform Input Controller.
Collisions work perfectly from anywhere but the front of my enemies! If I run into their back, the player collides perfectly. But in the front, I just go through them!
Same thing when THEY run in my direction, they go through me and go to my exact position, causing teleportation and weird bugs.
I use SetDestination(player.transform.position) to make the enemy follow me.
I would be very greatful to any idea, I've tried everything! NavMeshAgents on both, Rigidbodies, colliders, etc... :(
Thank you very much,
Charly.
I am having the exact same problem. Both my player and the enemy have a character controller, yet when i call on the enemy's navmeshagent.SetDestination(Player.Transform.Position) the enemy walks right through the player!
Adding a rigid body component did not fix the issue.
Answer by MightyBox · Sep 08, 2012 at 06:16 PM
Do your enemies also have a collider and a rigidbody attached to them? If not, that could be the problem. If attaching a rigidbody affects the movement of your navmeshagent, then make the rigidbody kinematic and that should remove its influence on navigator motion. This helped with a similar problem I had when I started using Unity's navigation system. Hope it helps you.
Answer by jediborg · Jan 07, 2014 at 12:46 AM
I found the answer here: http://answers.unity3d.com/questions/247770/how-do-i-stop-an-enemy-navmeshagent-from-intersect.html
Basically both the player and the enemy need a nav mesh agent attached so the agents are 'aware' of each other and don't collide