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
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");
}
}