- Home /
Zombie Round Script Help
I have a small problem with my zombie round script I've been tweaking. I've fixed 5 errors I've gotten with the script but I can't figure out what is causing an "expecting ), found :". But I've changed it to what it says but it errors again. If seeing the full script would help, let me know, I'll post it up. The error is at "maxlivezombies:int"
void Update()
{
while(GameObject.FindGameObjectsWithTag("zombie").length < maxLiveZombies:int || zombiesThisRound > maxZombies;
{
"expecting ), found :" obviously means that you forgot to close a parenthesis.
Answer by jolo309 · Jan 21, 2014 at 01:00 AM
void Update()
{
while(GameObject.FindGameObjectsWithTag("zombie").length < maxLiveZombies:int || zombiesThisRound > maxZombies);
{
would do it. You forgot a ) at the end of maxZombies, that should do it
Wait, Now I'm getting another error including the last error. It says the ) is an unexpected token.
What line and what script is that line, is it the same? Because if it is i can't really seem to find any other errors EDIT: Oh yeah try
void Update()
{
while(GameObject.FindGameObjectsWithTag("zombie").length < maxLiveZombies:int || zombiesThisRound > maxZombies)
{
ins$$anonymous$$d :D I wonder why i didn't see that before but you had a ; at the end
You fixed the error, (Thank You!) but now I'm getting an different error at (7, 9) and (12, 9) saying that void is not a macro. Here is the complete script:
var zombie:GameObject; //Set the zombie model in the inspector
var maxZombies:int; //set max zombies in this round
var maxLiveZombies:int; //set max zombies alive at once
private var zombiesThisRound:int = 0; //this is the number of zombies that have spawned this round, alive or dead
private var previousSpawnPoint:GameObject; //this is where the last zombie spawned
void Start()
{
previousSpawnPoint = GameObject.FindGameObjectsWithTag("spawnpoints")[0]; //this will break if you have no spawnpoints tagged "spawnpoints".
}
void Update()
{
while(GameObject.FindGameObjectsWithTag("zombie").length < maxLiveZombies)int || zombiesThisRound > maxZombies;
{
var spawnPoints = GameObject.FindGameObjectsWithTag("spawnpoints"); //get a list of all spawn points
var spawnPoint = previousSpawnPoint; //choose a default spawn point
while(spawnPoint == previousSpawnPoint && spawnPoints.length > 1) //keep choosing a random spawn point until you choose one you haven't choosen yet
{
var spawnPoint = spawnPoints[$$anonymous$$ath.floor($$anonymous$$ath.random() * spawnPoints.length)];
}
previousSpawnPoint = spawnPoint; //store where the zombie spawn last
var newZombie = Instantiate(zombie, spawnPoint.transform.position, spawnPoint.transform.rotation); //create the new zombie
newZombie.tag = "zombie"; //tag it as a zombie
zombiesThisRound++; //increase the number of spawned zombies.
}
}
Hmm, seems you use Javascript(UnityScript)
so ins$$anonymous$$d of void use
function
void is used for C#
var zombie:GameObject; //Set the zombie model in the inspector
var maxZombies:int; //set max zombies in this round
var maxLiveZombies:int; //set max zombies alive at once
private var zombiesThisRound:int = 0; //this is the number of zombies that have spawned this round, alive or dead
private var previousSpawnPoint:GameObject; //this is where the last zombie spawned
function Start()
{
previousSpawnPoint = GameObject.FindGameObjectsWithTag("spawnpoints")[0]; //this will break if you have no spawnpoints tagged "spawnpoints".
}
function Update()
{
while(GameObject.FindGameObjectsWithTag("zombie").length < maxLiveZombies)int || zombiesThisRound > maxZombies;
{
var spawnPoints = GameObject.FindGameObjectsWithTag("spawnpoints"); //get a list of all spawn points
var spawnPoint = previousSpawnPoint; //choose a default spawn point
while(spawnPoint == previousSpawnPoint && spawnPoints.length > 1) //keep choosing a random spawn point until you choose one you haven't choosen yet
{
var spawnPoint = spawnPoints[$$anonymous$$ath.floor($$anonymous$$ath.random() * spawnPoints.length)];
}
previousSpawnPoint = spawnPoint; //store where the zombie spawn last
var newZombie = Instantiate(zombie, spawnPoint.transform.position, spawnPoint.transform.rotation); //create the new zombie
newZombie.tag = "zombie"; //tag it as a zombie
zombiesThisRound++; //increase the number of spawned zombies.
}
}
Your answer
Follow this Question
Related Questions
ArgumentOutOfRangeException: Argument is out of range. Parameter name: index System. 0 Answers
Error in script 1 Answer
Error in script 1 Answer
Access components in ALL children 1 Answer
UCE0001: ';' expected. Insert a semicolon at the end 1 Answer