Hello,
I have a project in fmod where I’m trying to change a parameter on trigger enter in a script. The issue is that even though the variable that should make my sound play returns true, my sounds still don’t play. This is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WalkTriggers : MonoBehaviour {
public bool section1 =false;
public bool section2;
public bool section3;
public bool section4;
public bool section5;
// Use this for initialization
[FMODUnity.EventRef] public string Spencer;
private FMOD.Studio.EventInstance harpLoopInstance;
void Start () {
harpLoopInstance = FMODUnity.RuntimeManager.CreateInstance(Spencer);
harpLoopInstance.setVolume(0.0f);
harpLoopInstance.start();
}
// Update is called once per frame
void Update () {
if(section1 == true)
{
harpLoopInstance.setVolume(1.0f);
Debug.Log("yay");
harpLoopInstance.setParameterValue("Harp Volume", 1);
}
}
private void OnTriggerEnter(Collider collider)
{
if (collider.gameObject.tag == "Trigger1")
{
section1 = true;
harpLoopInstance.setParameterValue("Harp Volume", 1);
harpLoopInstance.setParameterValue("Drum Volume", 0);
harpLoopInstance.setParameterValue("Strings Volume", 0);
harpLoopInstance.setParameterValue("Flute Volume", 0);
}
}
}
Does anyone have any idea why its behaving this way?