public Transform redParticle;
void OnCollisionEnter(Collision collide)
{
if(collide.gameObject.tag == "bigRing")
{
Debug.Log ("You hit: " + collide.gameObject.tag);
var redEffect = Instantiate(redParticle, transform.position, transform.rotation) as GameObject;
Destroy (redEffect.gameObject, 3);
}
}
This is the collision code I have for my object, when a collision takes place, I would like the particle effect I have to play and then destroy it 3 seconds later, but at the moment, I receive the error
NullReferenceException: Object reference not set to an instance of an object
The particle effect is played, it’s just not being destroyed.
Anyone know what I’m doing wrong? Cheers