There's something I'm trying to achieve which is destroy an instantiated object (which is a Particle System). After doing some research, I found the way to instantiate and destroy the instantiated object is this:
public class CoinCollider : MonoBehaviour
{
public Transform coinEffect;
void OnTriggerEnter(Collider info)
{
if (info.name == "Ball")
{
GameObject effect = GameObject.Instantiate(coinEffect, transform.position, transform.rotation) as GameObject;
Destroy(effect);
Destroy(gameObject);
}
}
}
but it seems not to delete it, this object is inherited to one object which is being destroyed. But after making this destroy. it seems to create another gameObject with name "Particle System(clone)" with no parent. How to delete it?