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?