So I am trying to create a script that explodes a missile OnCollisionEnter2D. So far I have this script:
- var delay :float=2;
- functionOnCollisionEnter2D()
- {
- light.enabled =true;
- rigidbody2D.velocity =Vector2(0,0);
- animator.SetBool(“missileCollision”,true);
- yieldWaitForSeconds(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’ (Flickering Light - Unity Engine - Unity Discussions). 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??