- Home /
Question by
Maleesha_Safdari · Nov 10, 2017 at 02:09 PM ·
unity 5scipting
Enemy doesn't chase player
public class EnemyMove : MonoBehaviour {
*public Transform player;*
*private UnityEngine.AI.NavMeshAgent nav;*
private Animator anim;*
private EnemyHealth enemyHealth;*
void Awake()*
{ Assert.IsNotNull(player); }* *void Start () {* * player = GameManager.instance.Player.transform;* * enemyHealth = GetComponent<EnemyHealth> ();* * anim = GetComponent<Animator> ();* * nav = GetComponent<UnityEngine.AI.NavMeshAgent> ();* } void Update () { if (!GameManager.instance.GameOver && enemyHealth.IsAlive) { nav.SetDestination(player.transform.position); } else if ((!GameManager.instance.GameOver || GameManager.instance.GameOver) && !enemyHealth.IsAlive) { nav.enabled = false; } else { nav.enabled = false; anim.Play ("Idle"); } }
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612142647im_/https://answers.unity.com/themes/thub/images/avi.jpg)