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

RTS Movement

Discussion in 'Scripting' started by TheImperial, Jan 15, 2016.

  1. TheImperial

    TheImperial

    Joined:
    Mar 17, 2015
    Posts:
    72
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Finder : MonoBehaviour
    5. {
    6.     Vector3 DesPoint;
    7.    
    8.     void Update()
    9.     {
    10.         if(Input.GetMouseButtonDown(1))
    11.         {
    12.             DesPoint = new Vector3(Input.mousePosition.x,0f,Input.mousePosition.z);
    13.             transform.GetComponent<NavMeshAgent>().destination = DesPoint.transform.position;
    14.     }
    15. }
    16.  
    Parsing Error
     
  2. martinmr

    martinmr

    Joined:
    Mar 25, 2015
    Posts:
    325
    DesPoint is a Vector3 and a Vector3 hasnt' a transform,

    you have just to use

    Code (CSharp):
    1. transform.GetComponent<NavMeshAgent>().destination = DesPoint;
     
  3. TheImperial

    TheImperial

    Joined:
    Mar 17, 2015
    Posts:
    72
    still the same Error

    Code (CSharp):
    1. Assets/Scripts/Finder.cs(16,1): error CS8025: Parsing error
     
  4. martinmr

    martinmr

    Joined:
    Mar 25, 2015
    Posts:
    325
    ah ok, you missing the closing } from the if
     
    TheImperial likes this.
  5. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148