0

Estou com este erro:

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

Código:

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;
        //}
    }
}
2
  • Consegue provar que a tag é exatamente Player, e que ele já está na cena pra conseguir ser acessado pelo método? Porque não tem nada de errado no seu código.
    – DH.
    11/07/2016 às 16:37
  • muito bom. obrigado. 12/08/2016 às 23:09

0

Você deve fazer log-in para responder a esta pergunta.

Pesquise outras perguntas com a tag .