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. Dismiss Notice

Parsing Error?

Discussion in 'Scripting' started by eric56379, Oct 27, 2014.

  1. eric56379

    eric56379

    Joined:
    Mar 11, 2014
    Posts:
    89
    This script keeps giving this parsing error that says "Error CS8025 : Parsing Error"

    Here is the script:

    Code (CSharp):
    1. var target : Transform; //the enemy's target
    2. var moveSpeed = 3; //move speed
    3. var rotationSpeed = 3; //speed of turning
    4. var range : float=10f;
    5. var range2 : float=10f;
    6. var stop : float=0;
    7. var myTransform : Transform; //CURRENT TRANSFORM data of this enemy
    8. function Awake()
    9. {
    10.     myTransform = transform; //cache transform data for easy access/preformance
    11. }
    12.  
    13. function Start()
    14. {
    15.     target = GameObject.FindWithTag("Player").transform; //target the player
    16.    
    17. }
    18.  
    19. function Update () {
    20.     //rotate to look at the player
    21.     var distance = Vector3.Distance(myTransform.position, target.position);
    22.     if (distance<=range2 &&  distance>=range){
    23.         myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
    24.                                                 Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime);
    25.     }
    26.    
    27.    
    28.     else if(distance<=range && distance>stop){
    29.        
    30.         //move towards the player
    31.         myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
    32.                                                 Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime);
    33.         myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
    34.     }
    35.     else if (distance<=stop) {
    36.         myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
    37.                                                 Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed*Time.deltaTime);
    38.     }
    39.    
    40.    
    41. }
    Thanks a lot!
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,398
    If the error says "CS" that means you're trying to use a C# script, but the code isn't C#, it's Unityscript.

    --Eric
     
  3. eric56379

    eric56379

    Joined:
    Mar 11, 2014
    Posts:
    89
    Wow! You replied fast. I will change the script so that it's JS, and see if that fixes it. Thanks!
     
  4. eric56379

    eric56379

    Joined:
    Mar 11, 2014
    Posts:
    89
    Fixed, thanks!