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);
}
}
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
반응형
'게임엔진(GameEngine) > Unity3D' 카테고리의 다른 글
ExecuteInEditMode, RequireComponent (0) | 2018.02.16 |
---|---|
ArgumentException: Input Button Submit is not setup (0) | 2018.01.18 |
AnimationState.normalizedTime (0) | 2018.01.14 |
IsPointerOverGameObject 화면과 UI 클릭을 구분하기 (0) | 2018.01.14 |
Important lightmap setting (0) | 2018.01.06 |