Setting parameter of event emitter does not seem to stick

Hi all, so I got this problem with the event emitter. The background is that I am trying to make footstep sounds based on the material the player is stepping on, so I declare an int and assign it based on the tags of the stepped object, then have the emitter play the event. The problem is, when I try to assign it to the emitter’s parameter called ‘Terrain’, the very next frame, it does not stick at all. For example, if I assign the terrain parameter with 1 when it was originally 0, the next frame, it is still 0.

Here’s the code, it will be called every update call:

  	int mat = SoundNamespace.FMODMaterialHelper.UnityToFMODMaterial(hit.transform.tag);
  	if (mat != _currMaterialIndex)
        {
  		_emitter.SetParameter("Terrain", mat);
  		_currMaterialIndex = mat;

  	}

And I use

_emitter.Play();

to actually play the sound.

The only way for the parameter to stick is if I remove the if (mat != _currMaterialIndex) line but then it would setParameter every time and the result is the same if I do this way

_emitter.eventInstance.SetParameterByName(“Terrain”,mat);

Whats the problem with my code?

Hi,

What version of FMOD and Unity are you using?

Would it be possible to get the full script you are using uploaded to your Profile or DM’d to me?

If you run a Profiler (FMOD Studio | Profiling), is the same instance of the event being played throughout? Or are you creating multiple instances? If it is the latter, each time a new instance is created, its parameters will be reset to their original value. There are two options, make the parameter global so that once the value is changed it will remain irrespective of the event instance (FMOD Studio | Parameters). The other option is continuing the same instance the whole time and just silencing it instead of stopping it when you want it to stop.

Hope this helps!