footsteps overlapping?

Hi everyone
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

Hi Micha,

To trigger a key off, you just call EventInstance.getCue “KeyOff”, then trigger that cue.

Something like this:

	[code]

var eventInstance = FMOD_StudioSystem.instance.getEvent("/MyEvent");
FMOD.Studio.CueInstance cue;
eventInstance.getCue(“KeyOff”, out cue);
cue.trigger();
[/code]

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.

1 Like

Dear Peter,
how do i trigger the “keyoff” (manual page 243) that makes the cursor advance on the timeline when it is on a sustain point?
Micha

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.

Thank you!

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:

		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() );

Note that release() 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.

Thank you so much, this help a lot!
Micha