- Home /
[solved] respawn when destroyed
Hello, I can't figure out how to respawn game object if it's destroyed. The Game object have this script atached:
function OnTriggerEnter () {
Destroy(gameObject);
}
and my spawn control looks like this:
var spawnpoint : Transform[]; var pickup : GameObject[]; var objectcounts = 3;
function Start () { Spawn(); } function Spawn() { for (i=0; i<objcetcoun; i++) { var obj : GameObject = pickup [Random.Range(0,pickups.Length)] ; var pos : Transform = spawnpoint[Random.Range(0, spawnpoint.Length)]; Instantiate (obj, pos.position, pos.rotation); }
}
now when i pres play it spawns 3 objcets, but when i touch them they get destroyed, so what i need to do so the destroyed object respawns?
Thanks :)
Answer by Jessy · Jan 18, 2011 at 03:44 PM
Start is called once, so you're only spawning once. Run the Spawn function again at a later point.
maybe u can paste some simple Script, cuz i just can't figure it out :(
never$$anonymous$$d. i figured out by myself. anyway thanks for help :) cheers!!!
Please close the question or provide an answer and then mark it as answered.
Your answer
Follow this Question
Related Questions
How can I create New GameObject (Instantiate) 1 Answer
Spawn Random Item On Trigger Enter 2 Answers
move gameobject into a random position and the spawn an enemy 1 Answer
Random textures... 1 Answer
Trouble with a respawn script 1 Answer