I have recently asked for help on how to have a script where I have 10 to 12 spawn points as empty gameobjects around the map and adding tags to 8 of my objects as “SpawnPoint” and the script would place all 8 in any of those 10 to 12 spawn points. Link is here.
I’m still very new to scripting and I have a javascript that I experimented on and I would like some help on if I did this right and how to make a loop with the answer that I got
"Make a loop that will run 10 times.
In the loop use
var r = Random.Range(0,9)" <— (This is for 10 times right now, not 12)
My terrible script:
#pragma strict
var prefab : GameObject;
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;
var position = listofspwanpointas[r].transform.position;
function Start()
{
var objs = GameObject.FindGameObjectsWithTag("SpawnPoint");
for (var obj in objs)
}
}
function CreateObject()
{
Instantiate(prefab,vecArray[Random.Range(0,top)],Quaternion.identity);
}
I’m also getting this error
“Assets/SpawnScript.js(24,5): BCE0043: Unexpected token: }.”
If I adjust it I get 4 new errors:
“Assets/SpawnScript.js(24,5): BCE0043: Unexpected token: }.”
“Assets/SpawnScript.js(26,10): BCE0044: expecting (, found ‘CreateObject’.”
“Assets/SpawnScript.js(26,24): UCE0001: ‘;’ expected. Insert a semicolon at the end.”
“Assets/SpawnScript.js(28,74): BCE0044: expecting :, found ‘;’.”
Help on revising my script to be how it should be from my recently asked question would be tremendously appreciated! This is the last thing I need to do to make my game complete to publish on Google Play, to give my game replay value.