Parameter change not working

Hi! I’m trying to change parameter values on an event based on the velocity of the object it’s attached to. The event is triggered correctly and the values I get using collision.relativeVelocity.magnitude seem ok too but the parameter values don’t seem to change.

I’m just starting to learn audio integration, so I guess I’m doing some things wrong?

Thanks in advance for your help :slight_smile:

Here is my script

using UnityEngine;
using System.Collections;

public class collision_sfx : MonoBehaviour
{
[Space] [FMODUnity.EventRef] public string audioEvent;

FMOD.Studio.EventInstance instance;
FMOD.Studio.EventDescription instanceDescription;
FMOD.Studio.PARAMETER_DESCRIPTION pd;
FMOD.Studio.PARAMETER_ID pID;

 private float objectVelocity;   

 void Start ()   
 {
     instance = FMODUnity.RuntimeManager.CreateInstance(audioEvent);

     instanceDescription = FMODUnity.RuntimeManager.GetEventDescription(audioEvent);
     instanceDescription.getParameterDescriptionByName("Velocity", out pd);
     pID = pd.id;

 }    

 void OnCollisionEnter ()
 {

     objectVelocity = collision.relativeVelocity.magnitude;
     instance.start();
     instance.setParameterByID(pID, objectVelocity);
     instance.release();
     Debug.Log("bang");

 }

}

I’ve been able to create an event instance and set parameters using the script you provided.

I suspect either the event instance’s parameter is set to not change value once instantiated (eg. the “Hold value during playback” on the parameter properties) or perhaps has a velocity set on it that instantly puts its value back to 0.

Could you confirm you are able to make changes to this parameter and hear them in game without using the collision setup? Just a simple script that starts and sets the parameter value of this event instance.

What version of Unity are you using? I might be having a similar problem.