Question by 
               IshanCK · Jul 17, 2017 at 09:44 PM · 
                c#unity 5errorerror messageerror-message  
              
 
              Nav Mesh Problem with SetDestination
Why does this work this pops up 
 public float deathDistance = 0.5f;
 public float distanceAway;
 public Transform thisObject;
 public Transform target;
 private NavMeshAgent navComponent;
 void Start() 
 {
     target = GameObject.FindGameObjectWithTag("Player").transform;
     navComponent = this.gameObject.GetComponent<NavMeshAgent>();
 }
 void Update() 
 {
     float dist = Vector3.Distance(target.position, transform.position);
     if(target)
     {
         navComponent.SetDestination(target.position);
     }
     else
     {
         if(target == null)
         {
             target = this.gameObject.GetComponent<Transform>();
         }
         else
         {
             target = GameObject.FindGameObjectWithTag("Player").transform;
         }
     }
     if (dist <= deathDistance)
     {
         //KILL PLAYER
     }
 }
 
               
                 
                screen-shot-2017-07-17-at-54034-pm.png 
                (10.2 kB) 
               
 
              
               Comment
              
 
               
              Answer by FortisVenaliter · Jul 17, 2017 at 09:45 PM
Usually it's because your NavMeshAgent is inactive, or is not on the NavMesh.
Whether the "Active" box is checked in the inspector.
It says fail to create agent because there is no valid Nav$$anonymous$$esh

 
                      
                     screen-shot-2017-07-17-at-55240-pm.png 
                     (301.9 kB) 
                    
 
                   Your answer
 
             Follow this Question
Related Questions
I have an error on a C# script @username 2 Answers
Unable to join player connection alternative multicast group. 1 Answer
I Have an C# error and I can't fix it @username 1 Answer
Error stage @username 1 Answer
error CS0201 1 Answer