- Home /
Trouble calling a function...
Hello. This is the function I want to call.
function SPAWNER (){
for (var A = 0; A < 10; A++)
Instantiate(SPAWN[0], new Vector3(Random.Range(-31, 21), -1, Random.Range(-8, 15)), Quaternion.identity);
for (var B = 0; B < 1; B++)
Instantiate(SPAWN[1], new Vector3(Random.Range(-31, 21), -1, Random.Range(-8, 15)), Quaternion.identity);}
When I call it with:
function Start () {Invoke ("SPAWNER", 0);}
It works fine. But, when I try to call it with this (it is in another script) It doesn't work, and the console just says "Trying to Invoke method: Breakout_Weapon.SPAWNER couldn't be called.". What is wrong? Thanks
function OnTriggerEnter (other : Collider){
if (other.collider.name == "Goal(Clone)") {Breakout_Player.SCR+=500*Breakout_Player.WAV; Destroy (other.gameObject); Invoke ("SPAWNER", 0);}}
Comment
Best Answer
Answer by Justin Warner · Dec 30, 2010 at 05:26 AM
Why not put an empty game object where you want the "trigger" to be, and get the distance between the player and the game object, and so...
//Make this only happen once (Can be per a spawner if you put it on the empty gameobject) var times = 0;
if(Distance <= 1 && times == 0) { SPAWNER(); times++; }
Put that in the update function by the way...
Hope this helps!
Your answer
