NullReferenceException: Object reference not set to an instance of an object

1

I'm having this error:

  

NullReferenceException: Object reference not set to an instance of an   object EnemyMovement.Awake () (at   Assets / Scripts / Enemy / EnemyMovement.cs: 13)

Code:

using UnityEngine;
using System.Collections;

public class EnemyMovement : MonoBehaviour
{
    Transform player;

    NavMeshAgent nav;


    void Awake ()
    {
        player = GameObject.FindGameObjectWithTag ("Player").transform;

        nav = GetComponent <NavMeshAgent> ();
    }


    void Update ()
    {
        //if(enemyHealth.currentHealth > 0 && playerHealth.currentHealth > 0)
        //{
            nav.SetDestination (player.position);
        //}
        //else
        //{
        //    nav.enabled = false;
        //}
    }
}
    
asked by anonymous 11.07.2016 / 01:36

0 answers