This is so simple that I know I’m going to feel like a dunce when someone tells me what’s wrong with this.
So I have a prefab of a particle system that plays as the character walks around. (It’s water splashing around his feet). I have the following code on a collider and everything works fine; the particles show up as he walks where they’re supposed to.
However they’re not being destroyed in the hierarchy. So at the end of the level I have a zillion particle clones clogging it up even though they’re not visible in the scene. Here’s my code:
public ParticleSystem waterSplash;
public GameObject constructor;
void Start () {
}
void Update () {
}
void OnTriggerEnter(Collider other)
{
if(other.gameObject.CompareTag("Player"))
{
print( "collided!");
GameObject newSplash = Instantiate (waterSplash, constructor.transform.position, constructor.transform.rotation) as GameObject;
Destroy(newSplash, 2);
}
}
}