I am playing a sound like this:
public EventReference sound;
public void PlaySound()
This works, but I need to stop it early sometimes.
What is the simplest way to stop playing this sound before it finishes?
To stop an event instance before its natural end, you need a reference to it, which
PlayOneShot() obviously doesn’t give you. However,
PlayOneShot() is simply executing the following code,
var instance = RuntimeManager.CreateInstance(/* your EventReference here */);
so I’d recommend copying that code and using it instead of calling
PlayOneShot(), and storing the instance yourself so you can call
instance.stop() with the appropriate stop mode when needed.
Hope that helps!
Thanks for the reply again Louis, this definitely helps!
Though this does bring up two questions:
For the line:
This is if I want 3D sound, i.e, sound that plays relevant to the listener, right? If I want the sound to be uniform and the same volume, (2D?) can I just leave this out?
Is this different than instance.stop()? Do I need to release every instance that I store in addition to stopping it?
Thanks again for taking the time!
Makes perfect sense! Thanks for the assistance!