I am making a horror game. When the player pass through a trigger collider, the enemy will spawn. I want the enemy prefab to be disabled after a random amount of time between for example 1 and 10 seconds?
var timeOut = 1.0;
var detachChildren = false;
function Awake ()
{
Invoke ("DestroyNow", timeOut);
}
function DestroyNow ()
{
if (detachChildren) {
transform.DetachChildren ();
}
DestroyObject (gameObject);
}