Hello, I’ve used this method a lot in a previous project, but now it doesn’t seem to be working. Actually it does work if I use StudioEventEmitter.SetParameter(…) in my Update() function, but it doesn’t work if I use it in any one-time calls.
For instance, I want to modulate an impact sound in OnCollisionEnter() like this:
using UnityEngine;
using FMODUnity;
public class Drum : MonoBehaviour
{
public float minImpact = .05f;
public float impactVelocityThreshold = 20f;
public StudioEventEmitter drumSound;
private void OnCollisionEnter(Collision collision)
{
float hitForce = Mathf.Clamp01(collision.relativeVelocity.sqrMagnitude / impactVelocityThreshold);
//Debug.Log("Hit Drum. Force = " + hitForce);
if (hitForce > minImpact)
{
drumSound.SetParameter("HitForce", hitForce);
drumSound.Play();
}
}
The code doesn’t return any errors but it doesn’t effect the sound either, it doesn’t seem like the parameter is being set. (I’ve double checked the spelling and the parameter’s automation curves.) Any idea what I should check for or if I should use a different method? Thanks so much for your time