- Home /
Question by
briancas94 · Jul 13, 2016 at 09:27 AM ·
unity 2dcollider2dparticlesystemparticle systemparticle
particle effect repeat twice after collision
So I have this issue When my object collide(Rock) , it performs an particle effect (rock into pieces) in the same position the rock collied, It supose to perform this effect per object (in this case 2 rocks), the first attempt the 2 rocks collide in the ground and perform the effect the way I want, Awesome, then around 2 seconds later, my effect apears again, but without any objects colliding and in the same spot, So I want to prevent that and only perform the effect once per object collide
Here is my Code:
using UnityEngine;
using System.Collections;
public class destroy_meteor : MonoBehaviour {
public ParticleSystem meteor_d_effect;
void OnCollisionEnter2D (Collision2D col)
{
if (col.gameObject.name == "meteor1" ||
col.gameObject.name == "meteor2"
) {
Instantiate(meteor_d_effect, col.gameObject.transform.position, col.transform.rotation);
Destroy (col.gameObject);
}
}
}
Comment