- Home /
Making a Flickering Light Without Yield WaitForSeconds
So I am trying to create a script that explodes a missile OnCollisionEnter2D. So far I have this script:
var delay : float = 2;
function OnCollisionEnter2D()
{
light.enabled = true;
rigidbody2D.velocity = Vector2(0,0);
animator.SetBool("missileCollision", true);
yield WaitForSeconds(delay);
Destroy(gameObject);
}
Now I want to add a flickering light effect. The problem is that I can only figure out how to do it using 'yield WaitForSeconds' (http://forum.unity3d.com/threads/flickering-light.4988/). This causes further delay to the Destroy(gameObject) due to there being multiple 'yield WaitForSeconds' statements, which I do not want. Is there another way to accomplish this??
have you tried adding the second delay parameter to the Destroy call?
Destroy (gameObject, 2f);
So, the real problem is you want to hide a gameObject right away, but also have it last, invisibly, for a few seconds longer?
It's possible to turn off just the 3D model part (or even to destroy just the model.) Or, you're probably also spawning an explosion particleSystem? You could put the flickering light on there.
Your answer
Follow this Question
Related Questions
trigger spot light to turn on 3 Answers
How to get the lights positions from within a shader? 0 Answers
Check if an object has a light shining on it 1 Answer
dim light as actor moves away 1 Answer
Problem with Light 0 Answers