L'unité - “SetDestination” ne peut être appelé un agent actif qui a été placé sur une NavMesh. UnityEngine.NavMeshAgent:SetDestination(Vector3)

Je suis en utilisant Unity5 droit maintenant. J'ai eu cette erreur lorsque vous essayez de setDestination.

"SetDestination" ne peut être appelé un agent actif qui a été placé sur une NavMesh.
UnityEngine.NavMeshAgent:SetDestination(Vector3)
CompleteProject.EnemyMovement:mise à Jour() (Actif/_CompletedAssets/Scripts/Ennemi/EnemyMovement.cs:30)

Mon code.

using UnityEngine;
using System.Collections;

namespace CompleteProject
{
    public class EnemyMovement : MonoBehaviour
    {
        Transform player;               //Reference to the player's position.
        PlayerHealth playerHealth;      //Reference to the player's health.
        EnemyHealth enemyHealth;        //Reference to this enemy's health.
        NavMeshAgent nav;               //Reference to the nav mesh agent.


        void Awake ()
        å{
            //Set up the references.
            player = GameObject.FindGameObjectWithTag ("Player").transform;
            playerHealth = player.GetComponent <PlayerHealth> ();
            enemyHealth = GetComponent <EnemyHealth> ();
            nav = GetComponent <NavMeshAgent> ();
        }


        void Update ()
        {
            //If the enemy and the player have health left...
            if(enemyHealth.currentHealth > 0 && playerHealth.currentHealth > 0)
            {
                //... set the destination of the nav mesh agent to the player.
                nav.SetDestination (player.position);
            }
            //Otherwise...
            else
            {
                //... disable the nav mesh agent.
                nav.enabled = false;
            }
        }
    }
}

S'il vous plaît conseils. Merci.

Référence: https://github.com/datomnurdin/SurvivalShooter

Avez-vous cuit un navmesh dans votre scène? Est l'agent sur le maillage?
comment assurez-vous que?

OriginalL'auteur Mohammad Nurdin | 2015-05-28