반응형

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?

  1. public class Creature : MonoBehaviour
  2. {
  3. void OnTriggerEnter(Collider other) {
  4. Debug.Log ("yyy " + other.gameObject.name);
  5. }
  6. void OnCollisionEnter(Collision collision) {
  7. Debug.Log ("xxx " + collision.other.name);
  8. }
  9. }

alt text






You should attach a Rigidbody (set Kinematic on) and a collider on your navmesh agent, and you will receive OnTrigger callbacks.



https://answers.unity.com/questions/1213909/navmeshagent-and-collision.html

반응형

+ Recent posts