When I have the player walking and the enemy model static, they collide with each other as expected.
When I make the enemy a Nav Mesh Agent, they stop colliding.
If I use Ctrl+D to create multiple Nav Mesh Agent enemies , they collide with each other, but still not with the player model.
Why will they no longer collide with my player model, and how can I get them to? As a top-down shooter, it’s quite important. (The player is using the ‘character controller’ and collides with every other object.)
Just add a NavMeshAgent
component to the player as well. The enemies, being NavMeshAgent
s are driven around using an entirely different system than physics or CharacterControllers
, instead being driven by CrowdManager
(see the profiler). They’re only aware of other entities that are driven by the CrowdManager, and only if their avoidance
property is set to something other than None
(obviously the better the avoidance quality the more resources are required).
Adding a NavMeshAgent
component to the player - even if you keep moving it around with the CharacterController
! - will allow the other NavMeshAgent
s to perceive it and avoid collision with it.
A nice side-effect of this is that your player will be able to push enemies aside as it’s colliding with them, which could be useful to, say, throw enemies off cliffs and to oblivion.
I attach a NavMeshObstacle to the player and that seems to work.
NavMeshObstacle documentation
Use it with carving unchecked. It mentions using this for player characters: “This mode is best used in cases where the obstacle is constantly moving (for example, a vehicle or player character)”
@asafsitner I know this is old but I have queries/ Setting the Navmesh on my player that is driven by Characther Controller messes with the ground check of my Charachter controller. Also the Friendly NPC walks underneath my player while pathfinding. If no Navmesh is attached to playe it walks throuh player. Any advice.