Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Navmesh agent problem| navmeshagent.destination does not exist???

Discussion in 'Navigation' started by andreapomposelli, Sep 11, 2015.

  1. andreapomposelli

    andreapomposelli

    Joined:
    Apr 24, 2014
    Posts:
    5
    since i have upgrade to the 5.2 when i try to make an agent the console go crazy.i cant figure it out.
    this is one of seven errors of the origina unitypackage "Mecanim example scene".pls some help??
    Assets/Scripts/Agent.cs(43,31): error CS1061: Type `NavMeshAgent' does not contain a definition for `destination' and no extension method `destination' of type `NavMeshAgent' could be found (are you missing a using directive or an assembly reference?)
     
  2. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
  3. naimish1308

    naimish1308

    Joined:
    Jul 10, 2018
    Posts:
    5
    Same Problem
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.AI;
    5.  
    6. public class PeopleNavMesh : MonoBehaviour
    7. {
    8.     public bool isMoving;
    9.    
    10.     public Transform Transform;
    11.     void Start()
    12.     {
    13.      
    14.         Transform = GetComponent<Transform>();
    15.         NavMeshAgent nav = GetComponent<NavMeshAgent>();
    16.         nav.destination = transform.position;
    17.     }
    18.  
    19.     // Update is called once per frame
    20.     /*void Update()
    21.     {
    22.        
    23.         if (isMoving)
    24.         {
    25.             Invoke("Move", 10);
    26.         }
    27.     }
    28.     void Move()
    29.     {
    30.        
    31.     }*/
    32.    
    33. }
    34.  
     
  4. naimish1308

    naimish1308

    Joined:
    Jul 10, 2018
    Posts:
    5
  5. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    You also get the error "error CS1061: Type `NavMeshAgent' does not contain a definition for `destination' and no extension method `destination' of type `NavMeshAgent' could be found (are you missing a using directive or an assembly reference?)"? This could be a very broad issue. I'd try just reimporting your whole project, this is not a code issue for as far as I can see in your case.
     
    naimish1308 likes this.
  6. naimish1308

    naimish1308

    Joined:
    Jul 10, 2018
    Posts:
    5
    i reimported but no use wat shud i do
     
  7. naimish1308

    naimish1308

    Joined:
    Jul 10, 2018
    Posts:
    5
  8. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    Okay, is that the only error you're getting? If not, please send us a clear picture of your error log.
     
  9. joshuatg777

    joshuatg777

    Joined:
    Aug 15, 2020
    Posts:
    6
    I get the same error and came here to find an answer. This is the copy-pasted error:

    "Severity Code Description Project File Line Suppression State
    Error CS1061 'NavMeshAgent' does not contain a definition for 'SetDestination' and no accessible extension method 'SetDestination' accepting a first argument of type 'NavMeshAgent' could be found (are you missing a using directive or an assembly reference?) Assembly-CSharp C:\Users\joshu\BeanGoBRRRRRRRRR\Assets\Scripts\DefTest.cs 33 Active"

    Only difference is I tried to use SetDestination instead of desination, but when I tried destination as well, it got the same error
    I need help with this as well.
     
    Last edited: Sep 15, 2020
    dhrdina06 likes this.
  10. justin123089

    justin123089

    Joined:
    May 17, 2016
    Posts:
    4
    I think unity changed some stuff it worked 2 years ago.
     
  11. joshuatg777

    joshuatg777

    Joined:
    Aug 15, 2020
    Posts:
    6
    I tried it again with a later version of Unity, and it worked fine the way it was supposed to. I think it was just an issue with that version.
     
  12. spinnerbox

    spinnerbox

    Joined:
    Aug 14, 2015
    Posts:
    27
    I just changed the SetDestination line with

    Code (CSharp):
    1. agent.destination = hit.point;
    And it compiled.

    My script was:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.AI;
    3.  
    4. public class Player: MonoBehaviour {
    5.  
    6.     public Camera cam;
    7.  
    8.     public NavMeshAgent agent;
    9.  
    10.     void Start()
    11.     {
    12.         agent = GetComponent<NavMeshAgent>();
    13.     }
    14.  
    15.     // Update is called once per frame
    16.     void Update ()
    17.     {
    18.         if (Input.GetMouseButtonDown(0))
    19.         {
    20.             Ray ray = cam.ScreenPointToRay(Input.mousePosition);
    21.             RaycastHit hit;
    22.  
    23.             if (Physics.Raycast(ray, out hit))
    24.             {
    25.                 agent.destination = hit.point;
    26.             }
    27.         }
    28.     }
    29. }
    as per this tutorial here:

    https://learn.unity.com/tutorial/unity-navmesh?uv=2019.4&projectId=5f60d859edbc2a001ee947ea

    This was in Unity 2017.2. Something confused Unity for some reason because SetDestination method worked before I added or did something in my project. But I cannot figure out what confused Unity...