Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by usename · Aug 31, 2013 at 05:47 PM · errorparsingunexpectedsymbol

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");
     }
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image robertbu · Aug 31, 2013 at 05:53 PM 0
Share

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.

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

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");
     }
 }    
         

}

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image usename · Sep 01, 2013 at 12:24 PM 0
Share

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"); } }

avatar image meat5000 ♦ · Sep 01, 2013 at 12:27 PM 0
Share

Did you copy it all properly? He got code hanging outta his box

avatar image usename · Sep 01, 2013 at 12:33 PM 0
Share

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?)

avatar image usename · Sep 01, 2013 at 12:38 PM 0
Share

Haha. It had copied the 10. into the script. That's why I got the error. Thanks for all your help. :)

avatar image
0

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges