- Home /
How Can I Make My Fire Effect Disappear After I Shoot Object?
Hi, I'm quite new to Unity, and I'm coding a basic First-Person Shooter in C#. Currently, when I shoot an object, the object and bullet disappear immediately and are replaced with one of the fire effects from the Standard Assets.
Here is the code I've used for that part:
void OnCollisionEnter (Collision collision) {
if (collision.gameObject.tag == "0") {
collision.gameObject.tag = "Untagged";
Instantiate (fireEffect, collision.transform.position, Quaternion.identity);
Destroy (gameObject);
Destroy (collision.gameObject);
}
}
I would like the fire effect to disappear also after maybe five or ten seconds, but I'm not sure how to code that. I've tried:
Destroy (instantiatedFire);
as well as:
Destroy (Instantiate (fireEffect, collision.transform.position, Quaternion.identity));
But, truthfully, I have no idea what I'm doing. Any help on coding this part would be very helpful.
Thanks!
Comment