Post by ricksaada on Oct 8, 2021 19:28:12 GMT
Here's what I'm trying to accomplish:
I have an effects sequence which is a mixture of particle effects, animations, sounds, or whatever. My manager figures out how long each thing is, when it's supposed to start relative to the previous things, and fires them off as needed.
So if I have a variable length animation of a molotov cocktail flying through the air and I need to sync the sound of the *woosh*, *smash*, *foomp* to start a quarter second before the animation ends, I can do it.
To do this, I need to be able to know how long each effect is (including the sounds). So what I tried to so was:
This seems like it ought to work, but I ran into several big snags. First, GetVariationLength doesn't actually work. Because you've got:
1. Figure out the length of a sound variation if I'm using addressables?
2. Can I pause it after loading and then start it at the right time in the effects sequence? Or am I stuck with restarting a new copy at that time because I can't keep one paused and not stopped/unloaded? Do I have to record the variation I got and then restart that one to be sure I get something that's the same length?
Thanks for any insight you can provide as to how to accomplish this.
I have an effects sequence which is a mixture of particle effects, animations, sounds, or whatever. My manager figures out how long each thing is, when it's supposed to start relative to the previous things, and fires them off as needed.
So if I have a variable length animation of a molotov cocktail flying through the air and I need to sync the sound of the *woosh*, *smash*, *foomp* to start a quarter second before the animation ends, I can do it.
To do this, I need to be able to know how long each effect is (including the sounds). So what I tried to so was:
psr = MasterAudio.PlaySound3DAtTransform(soundName, parent);
if (psr.SoundPlayed)
{
Debug.Log($"started sound {soundName} paused at {Time.time}");
psr.ActingVariation.Pause();
return effectDuration = MasterAudio.GetVariationLength(psr.ActingVariation.SoundGroupName, psr.ActingVariation.GameObjectName);
}
Then, when it came time for this sound to actually play in the sequence (after the pinning bottle is nearly done), I'd call
psr.ActingVariation.Unpause();
This seems like it ought to work, but I ran into several big snags. First, GetVariationLength doesn't actually work. Because you've got:
#if ADDRESSABLES_ENABLED
case AudioLocation.Addressable:
LogError("Variation '" + variationName + "' in Sound Group '" + sType +
"' length cannot be determined because it's an Addressable."); // can add support for this if needed. Not sure of the need.
return -1f;
#endif
So I faked up the length for now. But that wasn't enough. Calling Pause() surprisingly calls Stop() for addressables. And that means when you try and UnPause() it fails because you're not playing. It also results in your sound getting unloaded, because now you don't have any copies playing, and the addressables cleanup code tosses it. So clearly I'm doing all this wrong, since I seem to be working against the way it's designed to flow. What's the right way to:1. Figure out the length of a sound variation if I'm using addressables?
2. Can I pause it after loading and then start it at the right time in the effects sequence? Or am I stuck with restarting a new copy at that time because I can't keep one paused and not stopped/unloaded? Do I have to record the variation I got and then restart that one to be sure I get something that's the same length?
Thanks for any insight you can provide as to how to accomplish this.