- Home /
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 `}'
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");
}
Thanks my problems are gone now. Thank you guys for all the help.
There's a good chance the script you copied was outdated. Try FindGameObjectWithTag ins$$anonymous$$d of FindWithTag
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...
Your answer
Follow this Question
Related Questions
Error CS1525: Unexpected symbol `}' 1 Answer
Power up weapon shot before releasing and resetting power 1 Answer
error CS0120 1 Answer