So I am having some trouble with a simple parameterScript I made for unity using fmod. Whenever the player hits a triggerbox with this script and the right values filled in it should change a parameter in Fmod. Weirdly enough it works with the first trigger box but not the 2nd. Do you have any ideas what might be the problem?
Here is my script :
using UnityEngine;
using FMODUnity;
using FMOD.Studio;
public class ParameterScriptFmod : MonoBehaviour
{
[SerializeField] private string playerTag = "Player";
[SerializeField] private string parameterName;
[SerializeField] private float parameterValue;
[SerializeField] private string fmodEventPath;
private EventInstance fmodEventInstance;
private void Awake()
{
fmodEventInstance = RuntimeManager.CreateInstance(fmodEventPath);
}
private void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag(playerTag))
{
Debug.Log("ParamChange");
fmodEventInstance.setParameterByName(parameterName, parameterValue);
DestroyAudioTrigger();
Debug.Log("ParamChange");
}
}
private void Start()
{
fmodEventInstance.start();
}
private void OnDestroy()
{
// Release the FMOD event instance when the game object is destroyed
fmodEventInstance.release();
}
void DestroyAudioTrigger()
{
Destroy(gameObject);
}
}