Help, im trying to make my player spawn when the game starts and when he dies from touching a killzone tag. Yes this may not be the most efficient way to do by if you want you can fix it up, im getting 3 errors on line 26:
- ‘expecting ), found : ’
- ‘;’ expected. Insert a semicolon at the end
- Unexpected token: ).
Plz help i need this ASAP, and i have no idea what is wrong, i don’t even know how to use arrays but anything would be helpful, it is a merge of two scripts one detecting weather you have hit a killzone and the spawn script.
i have made shore that there are both java script
Sorry for my bad spelling
private var timer : float = 0.0;
private var spawning : boolean = false;
var prefab : GameObject;
var numspawns : float = 0;
var spawn1 : Transform;
var spawn2 : Transform;
var spawn3 : Transform;
var spawn4 : Transform;
var spawn5 : Transform;
var spawn6 : Transform;
var spawn7 : Transform;
var spawn8 : Transform;
var spawn9 : Transform;
var spawn10 : Transform;
var spawn11 : Transform;
var spawn12 : Transform;
function OnControllerColliderHit(hit : ControllerColliderHit)
{
if(hit.gameObject.tag == "Killzone")
{
Spawn();
}
else
{
OnControllerColliderHit(hit : ControllerColliderHit);
}
}
function Spawn()
{
//set spawning to true, to stop timer counting in the Update function
spawning = true;
//reset the timer to 0 so process can start over
timer = 0;
//select a random number, inside a maths function absolute command to ensure it is a whole number
var randomPick : int = Mathf.Abs(Random.Range(1,numspawns));
//create a location 'Transform' type variable to store one of 3 possible locations declared at top of script
var location : Transform;
//check what randomPick is, and select one of the 12 locations, based on that number
if(randomPick == 1){
location = spawn1;
Debug.Log("Chose pos 1");
}
else if(randomPick == 2){
location = spawn2;
Debug.Log("Chose pos 2");
}
else if(randomPick == 3){
location = spawn3;
Debug.Log("Chose pos 3");
}
else if(randomPick == 4){
location = spawn4;
Debug.Log("Chose pos 4");
}
else if(randomPick == 5){
location = spawn5;
Debug.Log("Chose pos 5");
}
else if(randomPick == 6){
location = spawn6;
Debug.Log("Chose pos 6");
}
else if(randomPick == 7){
location = spawn7;
Debug.Log("Chose pos 7");
}
else if(randomPick == 8){
location = spawn8;
Debug.Log("Chose pos 8");
}
else if(randomPick == 9){
location = spawn9;
Debug.Log("Chose pos 9");
}
else if(randomPick == 10){
location = spawn10;
Debug.Log("Chose pos 10");
}
else if(randomPick == 11){
location = spawn11;
Debug.Log("Chose pos 11");
}
else if(randomPick == 12){
location = spawn12;
Debug.Log("Chose pos 12");
}
//create the object at point of the location variable
var thingToMake : GameObject = Instantiate(prefab, location.position, location.rotation);
thingToMake.AddForce(Vector3(0,0,100));
//halt script for 1 second before returning to the start of the process
yield WaitForSeconds(1);
//set spawning back to false so timer may start again
spawning = false;
}