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 FishSaysBlub · Nov 21, 2014 at 03:53 PM · c#error message

error CS1525: Unexpected symbol `}'

I'm trying to make my game end when all my enemies died but I keep getting stuck. I'm new to Unity and I would apreciate some help. I got a script from internet and I'm Trying to adjust it to the way I want it. Here is the script im using at the moment:

using UnityEngine; using System.Collections;

public class EnemyHealth : MonoBehaviour {

 public int currentHealth;
 public int maximumHealth = 100;
 
 public float hbLength;
 
 // Use this for initialization
 void Start () {
     currentHealth = maximumHealth;
     /*
     hbLength = Screen.width / 2;
     */
     
 }
 
 // Update is called once per frame
 void Update () {
     ChangeHealth(0);
     if(currentHealth <= 0)Destroy(gameObject);
     if (GameObject.FindWithTag ("Enemy") == null) 
         print ("Good Job you killed them all");
     Application.LoadLevel ("Game Over Screen")
 }
 /*
 void OnGUI (){
     GUI.Box (new Rect(10, 10, hbLength, 30), currentHealth + " / " + maximumHealth);
 }
 */
 public void ChangeHealth (int health) {
     currentHealth += health;
 }

}

I would realy apreciate any help and suggestions. oh and the error I keep getting is:Assets/EnemyHealth.cs(27,9): error CS1525: Unexpected symbol `}'

Comment
Add comment · Show 5
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 MrSoad · Nov 21, 2014 at 03:46 PM 0
Share

Try replacing this :

 if (GameObject.FindWithTag ("Enemy") == null) 
          print ("Good Job you killed them all");
      Application.LoadLevel ("Game Over Screen")

With this :

 if (GameObject.FindWithTag ("Enemy") == null) { 
     print ("Good Job you killed them all");
     Application.LoadLevel ("Game Over Screen");
 }

avatar image FishSaysBlub · Nov 21, 2014 at 05:28 PM 0
Share

Thanks my problems are gone now. Thank you guys for all the help.

avatar image jdog98 · Nov 21, 2014 at 05:35 PM 1
Share

There's a good chance the script you copied was outdated. Try FindGameObjectWithTag ins$$anonymous$$d of FindWithTag

avatar image jdog98 · Nov 21, 2014 at 05:48 PM 0
Share

And use Debug.Log ins$$anonymous$$d of print

avatar image NoseKills · Nov 21, 2014 at 05:59 PM 0
Share

The errors you are getting are clearly appearing because you are missing curly brackets, parenthesis or semicolons. @$$anonymous$$rSoad is on the right track because there was a semicolon missing after Application.LoadLevel ("Game Over Screen"). You just have to go through the class and check that the class definition is inside curly brackets and that all method definitions have both opening and closing curlies etc...

0 Replies

· Add your reply
  • Sort: 

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

6 People are following this question.

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

Related Questions

Error CS1525: Unexpected symbol `}' 1 Answer

Power up weapon shot before releasing and resetting power 1 Answer

Assets/Standard Assets (Mobile)/Scripts/SidescrollControl.js(33,18): BCE0020: An instance of type 'UnityEngine.Transform' is required to access non static member 'Find'. 2 Answers

error CS0120 1 Answer

How to give a speed to random spawned object? 1 Answer


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