Question by
yvl · Jul 09, 2016 at 06:39 PM ·
collidernavmeshagent
NavMeshAgent and collision
Hey guys, im new here, so sorry for stupid question :)
I am using NavMeshAgent for my player character and wanted to make so that when player is close enough to an enemy, enemy starts to attack him.
I was trying to use an internal to enemy unit collider (screenshot), but OnCollisionEnter/OnTriggerEnter events do not fire.
What am i doing wrong?
public class Creature : MonoBehaviour
{
void OnTriggerEnter(Collider other) {
Debug.Log ("yyy " + other.gameObject.name);
}
void OnCollisionEnter(Collision collision) {
Debug.Log ("xxx " + collision.other.name);
}
}
screen-shot-2016-07-09-at-192748.png
(37.8 kB)
Comment
Answer by cAyouMontreal · Mar 13, 2017 at 06:03 PM
You should attach a Rigidbody (set Kinematic on) and a collider on your navmesh agent, and you will receive OnTrigger callbacks.