FMOD Unity parameter

I don’t know what I’m doing wrong, I’ve looked endlessly on the API and unity and still my FMOD params won’t even budge. What about this code is wrong?

public class FMODPlayer : MonoBehaviour
{
float VA = 0;
float VA2 = 1;

FMOD.Studio.EventInstance ambiance;


// Start is called before the first frame update
 void Start()
{
    blam = FMODUnity.RuntimeManager.CreateInstance("event:/SFX/rotation");
    ambiance = FMODUnity.RuntimeManager.CreateInstance("event:/Ambience/Water");
    ambiance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject.transform));
    blam.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject.transform));
    ambiance.getParameterByName("VA", out VA);
    ambiance.start();
   /* ambiance.setParameterByName("VA", 0, false);*/
}



// Update is called once per frame
 void Update()
{

    if (Input.GetKey(KeyCode.Space))
    {
        
        FMOD.RESULT result = ambiance.setParameterByName("VA", VA2, false);
        Debug.Log("Spaceyman");
        Debug.Log(ambiance);
        Debug.Log(result);
    }



}



private void PlayParam()
{
    
}

}

Have you tried getting the parameter value after you’ve set it in your Update()-method? What value does it show you?


if (Input.GetKey(KeyCode.Space))
{
    //Setting the parameter to a new value
    FMOD.RESULT result = ambiance.setParameterByName("VA", 1f);

    //This print here
    ambiance.getParameterByName("VA", out float changedParamValue);
    Debug.Log($"ChangedParamValue: {changedParamValue}");

    Debug.Log("Spaceyman");
    Debug.Log(ambiance);
    Debug.Log(result);
}

Here’s also some standard-checks I usually do:

  • Double-check that the parameter in FMOD is called exactly the same as in the game code (ie. "VA")?
  • Have I built the banks again between tests?

Tell me how it goes! :slight_smile:

/Pablo

1 Like