Question by
issygirl · Feb 18, 2016 at 09:41 AM ·
error message
l have been having this on my script error CS8025: Parsing, l don't what to do
using UnityEngine; using System.Collections; using UnityEngine.UI;
public class Differentball : MonoBehaviour {
public GameObject[]spawnPoints;
public GameObject Enemy;
public Text countText;
private int count;
// Use this for initialization
void Start ()
{
spawnPoints = GameObject.FindGameObjectsWithTag("spawn");
count = 0;
SetCountText ();
}
// Update is called once per frame
void Update ()
{
GameObject[] enemies;
enemies = GameObject.FindGameObjectsWithTag ("Enemy");
if (enemies.Length >= 3) {
print ("too many enemies on the dance floor");
}
else
{
InvokeRepeating ("spawnEnemies", 1, 4f);
count = count + 1;
SetCountText ();
}
}
void SetCountText ()
{
countText.text = " count ; " + count.ToString ();
}
} void spawnEnemies ()
int SpawnPos = Random.Range (0, (spawnPoints.Length - 0));
Instantiate (Enemy, spawnPoints [SpawnPos].transform.position, transform.rotation);
CancelInvoke ();
}
}
Comment
2 of } after void SetCountText() and not after void spawnEnemies()? or is it just the text being weird?
Answer by Landern · Feb 18, 2016 at 02:31 PM
Remove the ending curly brace before the spawnEnemies method, this is closing the class and thus your error.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Differentball : MonoBehaviour
{
public GameObject[]spawnPoints;
public GameObject Enemy;
public Text countText;
private int count;
// Use this for initialization
void Start ()
{
spawnPoints = GameObject.FindGameObjectsWithTag("spawn");
count = 0;
SetCountText ();
}
// Update is called once per frame
void Update ()
{
GameObject[] enemies;
enemies = GameObject.FindGameObjectsWithTag ("Enemy");
if (enemies.Length >= 3) {
print ("too many enemies on the dance floor");
}
else
{
InvokeRepeating ("spawnEnemies", 1, 4f);
count = count + 1;
SetCountText ();
}
}
void SetCountText ()
{
countText.text = " count ; " + count.ToString ();
}
//} <--------------------------REMOVE ME AS I CLOSE THE CLASS DEFINITION leaving the method spawnEnemies crying in the corner wondering why no class wants it.
void spawnEnemies ()
int SpawnPos = Random.Range (0, (spawnPoints.Length - 0));
Instantiate (Enemy, spawnPoints [SpawnPos].transform.position, transform.rotation);
CancelInvoke ();
}
}