So I have this script which is meant to trigger a multi sound in fmod.
In FMOD I have set it up so it trigger the sound when you are close to it (2ft) .
It seems that when I first star the game, the player lands at 2ft, so I get sound.
But when I walk away and go back to the trigger point the sound doesn’t play again. I am pretty sure everything is set up correctly in FMOD, but there might be a problem with the script.
It seems to me that it doesn’t receive the values after the instant start.
Here’s the code if anyone can help, Tnxx ! :
using UnityEngine;
using System.Collections;
public class testDistance : MonoBehaviour {
public Transform player;
FMOD.Studio.EventInstance testDistanceEvent;
FMOD.Studio.ParameterInstance distance;
Vector2 direction;
public float Distance;
void Start (){
testDistanceEvent = FMODUnity.RuntimeManager.CreateInstance ("event:/testDistance");
testDistanceEvent.getParameter ("Distance", out distance);
testDistanceEvent.start();
}
void Update () {
float dist = Vector3.Distance(transform.position, player.position);
float diz;
//Distance.setValue (dist);
//Distance.getValue (out float diz);
testDistanceEvent.setParameterValue ("Distance", dist);
testDistanceEvent.getParameterValue ("Distance", out diz);
Debug.Log (dist);
}
}