Set parameter to specific value not working

Hey folks,

I’m trying to do a rather simple thing, but it isn’t working. All I want to do, is to change a parameter in FMOD to a specific value when a certain function gets called. This is what my code looks like:

public class PlayerMovement : MonoBehaviour { private FMOD.Studio.EventInstance P_Footstep; private FMOD.Studio.ParameterInstance Wood;
void PlaySound (string path)
	P_Footstep.setParameterValue("Wood", 1f);	
 	FMODUnity.RuntimeManager.PlayOneShot(path, transform.position);


The “PlaySound” function gets called whenever a certain animation is triggered. So far the function is working properly and the sound is being triggered. But unfortunately the parameter does not change to the given value. Everything is set up correctly within FMOD itself, as manually changing the parameter is just doing fine, but somehow Unity does not pass the value on to FMOD.

What am I missing?

PlayOneShot makes a ‘fire and forget’ event that plays once and cleans itself up. You cannot set parameters of these because you don’t have access to them using this function.

SetParameterValue is setting the parameter on the event instance you are calling it from, P_Footstep, you can have multiple event instances all with different current parameter values.

In short, it looks like you are setting the parameter of a stored EventInstance and then using PlayOneShot creates another instance with the default parameter values.

1 Like

I see, setParameter and PlayOneShot are referring to different instances of the same event. That makes it clear. Removing the PlayOneShot and calling the sound manually via RuntimeManager.CreateInstance at the beginning of the function, made them both now refer to the same event instance. Works like a harm now. Thank you very much.