Search Unity

NavMeshAgent.SetDestination(); does not take Vector3?

Discussion in 'Navigation' started by FeliXXL, Jul 4, 2018.

  1. FeliXXL

    FeliXXL

    Joined:
    Sep 14, 2016
    Posts:
    4
    Soo, i was "rebuilding" an example script in C#... well, this one:

    Code (CSharp):
    1. public class NavMeshAgent : MonoBehaviour {
    2.  
    3.     [SerializeField]
    4.     Transform _destination;
    5.  
    6.     NavMeshAgent _navMeshAgent;
    7.  
    8.     // Use this for initialization
    9.     void Start ()
    10.     {
    11.         _navMeshAgent = this.GetComponent<NavMeshAgent>();
    12.  
    13.         if (_navMeshAgent == null)
    14.         {
    15.             Debug.LogError("Nav mesh agent not attached to Component " + gameObject.name);
    16.         }
    17.         else
    18.         {
    19.             SetVector();
    20.         }
    21.     }
    22.  
    23.     private void SetVector()
    24.     {
    25.         if (_destination != null)
    26.         {
    27.             Vector3 targetVector = _destination.transform.position;
    28.             _navMeshAgent.SetDestination(targetVector);
    29.         }
    30.     }
    31. }
    And Visual Studio Points out that no overload of this Method takes 1 Argument. (would be line 28 here)
    So, i am a bit confused, because i cannot compile the script and the "error" is kind of against the logic presented in the documentation.
    Well, up to this point i am kind of screwed.

    I hope someone can point out what is going on / wrong because it does absolutely make no sense to me whatsoever.

    Thanks for your time.

    Felix
     
    Last edited: Jul 5, 2018
  2. FeliXXL

    FeliXXL

    Joined:
    Sep 14, 2016
    Posts:
    4
    Closed for being dumb... Yeah, naming is important, i get it :D
     
    Last edited: Jul 5, 2018