In the example below, the Start method is changed into a coroutine which turns on it's particle emitter, waits for T seconds, then turns it off. Without coroutines, this would be much messier.
using UnityEngine;
using System.Collections;
public class ParticleBurst : MonoBehaviour {
public float T = 1;
IEnumerator Start() {
particleEmitter.emit = true;
yield return new WaitForSeconds(T);
particleEmitter.emit = false;
}
}
No comments:
Post a Comment