Setting a Parameter FMOD 2.0 / Unity

Hey guys,

I’m still rather new to FMOD especially FMOD 2.0. What I’m trying to do is quiet simple I just don’t get it to run with FMOD 2.0 an the new Parameter API.

I basically want to create a dynamic acceleration sound using Unity (2018.3.12f1) and FMOD (2.0). The spacebar will be the trigger to accelerate.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FMODUnity;
using FMOD;

public class Acceleration : MonoBehaviour
{
// Start is called before the first frame update

float initialVelocity = 0.0f;
float finalVelocity = 100.0f;
float currentVelocity = 0.0f;
float acceleration = 10.0f;
float deceleration = 5.0f;

bool ignoreseekspeed = false;
/* [FMODUnity.EventRef]
 public FMOD.Studio.EventInstance Noise; */


// Update is called once per frame
void Update()
{
    if(Input.GetKey("space"))
    {
        currentVelocity = currentVelocity + (acceleration * Time.deltaTime);
    }
    else
    {
        currentVelocity = currentVelocity - (deceleration * Time.deltaTime);
    }

    currentVelocity = Mathf.Clamp(currentVelocity, initialVelocity, finalVelocity);

    print("ArrowPressed" + currentVelocity);

    RESULT Studio.EventInstance.setParameterByName("Velocity", currentVelocity, ignoreseekspeed);
    
}

}

Somehow it says that the last line “Studio.EventInstance.setParameterByName(…)” is not available in the current context.
Maybe I’m just misunderstanding the new Parameter API somehow. I’d be glad if someone can help me out with it.

Cheers!

You need to call setParameterByName on an Event Instance, not using the namespace.

For example:

[FMODUnity.EventRef]
public string eventName = "";
FMOD.Studio.EventInstance instance;

Start
{
    instance = FMODUnity.Runtimemanager.CreateInstance(eventName);
    ...
    instance.setParameterByName(...);
}