- Home /
This question was
closed May 09, 2013 at 09:37 AM by
Fattie for the following reason:
Duplicate Question
Question by
CYVISUALEFFECTS · May 09, 2013 at 08:41 AM ·
timehorror
Timed object destructor help!
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);
}
Comment
Best Answer
Answer by GC1983 · May 09, 2013 at 08:57 AM
function Awake()
{
Invoke( "DestroyNow", Random.Range(1, 10) );
}
expecting ), found "i" and "i" expected, insert a semicolon in the end
there was simply a missing bracket, I edited it.
you really should be able to figure out that sort of thing as a beginner programmer eh !
Always COUNT THE BRAC$$anonymous$$ETS to make sure they match.
Follow this Question
Related Questions
Objectives/Goals 1 Answer
AI Script Problem, Horror Game 0 Answers
How to delay a line of code. 2 Answers
Need help with this Rotation Script (fixes) 1 Answer
Increase health smoothly not instantly? 2 Answers