The prefab I chose to use for the AOE was from a really nice RPG FX pack. It had an audio effect on the prefab. It trails off quite a bit for a cool echo-y effect so when I try to kill the prefab it cuts out the audio abruptly. I remember from way back when that you can set the volume to 0 first to avoid this to a degree. Doing it right before the destroy did nothing… But doing this worked. Genius? Or Mad man?
private IEnumerator Effect(AbilityData data, Action finished)
{
Transform prefabInstance = Instantiate(prefabToSpawn);
prefabInstance.position = data.GetTargetedPoint();
if(destroyDelay > 0)
{
yield return new WaitForSeconds(destroyDelay * 0.98f);
AudioSource audio = prefabInstance.GetComponent<AudioSource>();
if(audio != null) audio.volume = 0;
yield return new WaitForSeconds(destroyDelay * 0.02f);
Destroy(prefabInstance.gameObject);
}
finished();
}
(The prefab has a custom script that handles audio playback and looping and stuff. I actually hacked it enough to where I don’t need to do that anymore, but it is a decent solution in a pinch)
Oh… I also wanted to ask why we aren’t using the overload for Destroy that takes a delay. This way we did leaves us more opportunities for other stuff… maybe?