Hi. I need a very simple script that will destroy a game object with a set tag after a certain amount on time set in a variable. Thank you!
Destroy(GameObject.FindWithTag("Tag Goes Here"), destroyDelay);
http://unity3d.com/support/documentation/ScriptReference/Object.Destroy.html
var timeToWait : float = 100.00 //this is 1 minute.
var timer : float;//this will change itself
var destroyed = false;
function Update()
{
//if(otherVar) {
timer += 1 * Time.deltaTime;
if(timer >= timeToWait)
{
if(!destroyed)
{
Destroy(gameObject.FindWithTag("GuiTexture"));
destroyed = true;
}
}
//}
}
i hope this helps, i'm using it to make a "stop game" effect. and the time and all works.