- Home /
CharacterController on player, NavMesh Agent on enemies: prevent player from walking over or pushing enemies?
What I'm trying to do: prevent player from pushing enemies or being able to walk over them.
What I have: Character Controller on player, player is able to jump, step on 1 unit high obstacles and is being pulled down by scripted gravity; enemies have NavMesh Agent component on them and Capsule Collider + Rigidbody so that projectiles could hit them;
What's the problem: even with 2 units high capsule colliders on enemies I can walk on them. If I add NavMesh Obstacle to player, I will be able to also push them, which is undesirable. If I add NavMesh Agent instead, player will not be able to jump.
Answer by Violet-n-red · Feb 22, 2017 at 08:26 PM
what i did: used OnControllerColliderHit (it is required to get collision between CharacterControlelr and anything else, nothing else seemed to work) and checked for colliding object's layer (my enemies are sitting in their own layer), then got collision's normal and multiplied it to make enemies forcibly push the player away.
Your answer
Follow this Question
Related Questions
"Nav Mesh Agent" messes up simple prototype player-gameobject. What's up with that? 0 Answers
Player "teleports" on top of NavMeshAgent collider if the Agent is too close 4 Answers
gameobject.GetComponent().target is not working 1 Answer
NavMeshAgent not fully reaching destination, thus it won't delete itself when it gets there 1 Answer
NavmeshAgent.remainingDistance remains at 0 but the agent still moves and behaves correctly 4 Answers