This sounds easy, but for me I’ve been hitting my head against it for over two days.
Anyway, I’ll keep it simple. Two objects: cannonball with particle effect, ocean with script to trigger splash and to destroy splash and cannonball x seconds after they hit the water.
My idea is this: Cannonball hits ocean, ocean fires particles, ocean grabs particles as a child (so particles stay right where they hit), then oceans destroys ball and emitter after x seconds (cannonball earlier, particles later).
Problem: Took a bit but here is the issue. The particle system doesn’t fire. What am I overlooking?
using UnityEngine;
using System.Collections;
public class CannonballEater : MonoBehaviour {
ParticleSystem mySplash;
private void OnTriggerEnter(Collider other)
{
mySplash = other.GetComponentInChildren<ParticleSystem>();
mySplash.Play();
mySplash.transform.parent = this.transform;
if (other.tag=="Cannonball")
Destroy(other.gameObject);
Destroy(mySplash.gameObject, 5f);
}
}