I’m trying to write a script that Destroys an object after 3 seconds, then waits 2 more seconds, then clones that object so it can continue. The problem I’m having is the object never gets destroyed. Here’s my code:
//Sphere Countdown
//Public Variables
var wait : int = 5;
//Private Variables
function CoUpdate ()
{
Destroy(gameObject,3);
yield WaitForSeconds(wait);
Instantiate(gameObject);
}
Also, is there any way I could call in another script when the object clones itself?
it's impossible since the script is destroyed with the object so it never gets to the point of instantiate.
First hi
Then Come On!
the script will go on till " Destroy(gameObject,3); " then it will destroy the object that script is in it! so it wouldn’t continue…
you can do 3 way :
1.move the script to onother gameobject
move the script to another gameobject and then use " gameobject.find " to find the object that need to be destroyed & then destroy it
3 or you can easily put destroy on the last line … and if you want to disapear it just for a few sec and then destroy it use " gameobject.renderer == false " …
it's impossible since the script is destroyed with the object so it never gets to the point of instantiate.
– TheDarkVoid