- Home /
Parsing Error : Unexpected symbol 'end of file'
I have no idea what's going on here. First unity tells me I need to add an extra curly bracket at the end but when I do I still get an error. Hope You Can find the problem.
 using UnityEngine;
 using System.Collections;
 
 public class PlayerController : MonoBehaviour
 {
     public float Speed;
     public GUIText countText;
     public GUIText winText;
     public GUIText Failtext;
     public int EnemyHits; 
     private int count; 
     
     void Start ()
     {
         count = 0;
         SetCountText ();
         winText.text = "";
     }
     
     void FixedUpdate ()
     {
         float moveHorizontal = Input.GetAxis("Horizontal");
         float moveVertical = Input.GetAxis("Vertical");
         
         Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
         
         rigidbody.AddForce(movement * Speed * Time.deltaTime);
     }
         void OnTriggerEnter(Collider other) 
     {
         if(other.gameObject.tag == "PickUp")
         {
             other.gameObject.SetActive(false);
             count = count + 1;
             SetCountText ();
         }
         else if (other.gameObject.tag == "EnemyPickUp")
         {
             other.gameObject.SetActive(false); 
             EnemyHits = EnemyHits + 1;
             SetCountText ();
    }
 }
         void ChangeScene ()
        {
        if (winText.text == ("Level Cleared!"))
             Application.LoadLevel("LevelCleared");
        }
               void SetcountText ()
        {
        countText.text = "Count: " + count.ToString ();
        {
        if(count >= 5)
        {
             winText.text = "Level Cleared!";
             Application.LoadLevel("LevelCleared");
        }
        else if(EnemyHits >= 2)
        {
            winText.text = "Level Failed";
            Application.LoadLevel("Fastgame2");
     }
If you place your cursor just in front of a '{', $$anonymous$$ono will highlight the matching cursor. Walk through your code checking the matching of the '{' to '}' to make sure your logic is the way you want it. The indentation of the code above makes debugging difficult. Line 52 is likely your issue.
Answer by citizen_rafiq · Aug 31, 2013 at 08:30 PM
//now it's ok
public class PlayerController : MonoBehaviour {
 public float Speed;
 public GUIText countText;
 public GUIText winText;
 public GUIText Failtext;
 public int EnemyHits;
 private int count;
 
 void Start ()
 {
     count = 0;
     SetCountText ();
     winText.text = "";
 }
 
 void FixedUpdate ()
 {
     float moveHorizontal = Input.GetAxis("Horizontal");
     float moveVertical = Input.GetAxis("Vertical");
  
     Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
  
     rigidbody.AddForce(movement * Speed * Time.deltaTime);
 }
 void OnTriggerEnter(Collider other)
 {
     if(other.gameObject.tag == "PickUp")
     {
         other.gameObject.SetActive(false);
         count = count + 1;
         SetCountText ();
     }
     else if (other.gameObject.tag == "EnemyPickUp")
     {
         other.gameObject.SetActive(false);
         EnemyHits = EnemyHits + 1;
         SetCountText ();
     }
 }
 void ChangeScene ()
 {
     if (winText.text == ("Level Cleared!"))
     Application.LoadLevel("LevelCleared");
 }
 void SetCountText ()
 {
     countText.text = "Count: " + count.ToString ();
     if(count >= 5)
     {
         winText.text = "Level Cleared!";
         Application.LoadLevel("LevelCleared");
     }
     else if(EnemyHits >= 2)
     {
         winText.text = "Level Failed";
     Application.LoadLevel("Fastgame2");
     }
 }    
         
}
I just pasted the your text into my script but now it's just putting red lines under all of these sentences.  countText.text = "Count: " + count.ToString (); if(count >= 5) { winText.text = "Level Cleared!"; Application.LoadLevel("LevelCleared"); } else if(EnemyHits >= 2) { winText.text = "Level Failed"; Application.LoadLevel("Fastgame2"); } }  
Did you copy it all properly? He got code hanging outta his box
I missed a curly bracket. That's why it put all the red lines under it. Now i only have one error. The one I started out with. error CS8025: Parsing error. When I click on it to show me the error it shows me that I should put a curly bracket at the end but when I do I get a new error. error CS1061: Type 'int' does not contain a definition for 'count' and no extension method 'Count' of type 'int' could be found (are you missing a using directive or an assembly reference?)
Haha. It had copied the 10. into the script. That's why I got the error. Thanks for all your help. :)
Answer by Paulius-Liekis · Aug 31, 2013 at 06:44 PM
It looks like you're missing } bracket. Fix indentation and you'll find the problem.
Your answer
 
 
             Follow this Question
Related Questions
GUI Button not working (Unexpected Symbol) 3 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Quill18's Tutorial Scripts: Unexpected Symbols 1 Answer
Getting errors on my chart script 1 Answer
When I try to disable mouse look for first person controller it throws an error 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                