we are trying to get an Fmod Studio project to run in Unity.
we have one event containing footstep sounds. So for every footstep we want to hear, we stop() and start() the emitter, which cuts off the footstep already playing from before… but we want the footsteps to overlap.
the only idea we have to do this would be to create a new emitter for every footstep we want to play. surely, that’s not the way to go, right?
thanks for any help!
- Micha asked 5 years ago
To trigger a key off, you just call EventInstance.getCue "KeyOff", then trigger that cue.
Something like this:
[code:3nfj9t0q]var eventInstance = FMOD_StudioSystem.instance.getEvent("/MyEvent"); FMOD.Studio.CueInstance cue; eventInstance.getCue("KeyOff", out cue); cue.trigger();[/code:3nfj9t0q]
Note: there is a typo in the current integration layer where CueInstance.trigger is actually called CueInstance.setValue, so for this to work in the current version just replace "trigger" with "setValue" and pass through any float, it will be ignored. This will be fixed in the next release of the integration.
[quote="peter":1c8xk5kk]There are a number of ways to approach this, the simplest would be to use a oneshot event for each step. So in script you call FMOD_StudioSystem.instance.PlayOneShot each time the characters foot collides with the ground.[/quote:1c8xk5kk]
Can i read up on those different apporaches anywhere?
my footstep sound event has a parameter called "surface", it gives a different sound depending on if you walk on concrete or snow.
so… when i call a oneShot event, how can i pass that parameter?
the only way i know for passing parameters is via the emitter, but oneShot sounds don’t use the emitter, right?
If you need to set a parameter then you will need to get the event instance. To play a one shot and set the parameter you would do something similar to what is inside the PlayOneShot function, something like this:
[code:2b5nl29l] var instance = getEvent(path);
var attributes = FMOD.Studio.UnityUtil.to3DAttributes(position); ERRCHECK( instance.set3DAttributes(attributes) ); FMOD.Studio.ParameterInstance param = null; ERRCHECK( instance.getParameter("surface", out param) ); ERRCHECK( param.setValue(1.0f) ); ERRCHECK( instance.start() ); ERRCHECK( instance.release() );[/code:2b5nl29l]
Note that [b:2b5nl29l]release()[/b:2b5nl29l] is called immediately after start, this is how to make a ‘one shot’. Once you call release it will play out the sound to completion and release the event. Note that this requires that the event is not endless, if the runtime cannot determine whether the event will terminate release will return an error.
Please login first to submit.