Parameter not responding.

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. :slight_smile:
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. :confused:

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


}

}

This is another simplified version I tried but doesn’t work either. :confused:
using UnityEngine;
using System.Collections;

public class testDistance : MonoBehaviour {

public Transform player;
public string position; 

FMOD.Studio.EventInstance testDistanceEvent; 
FMOD.Studio.ParameterInstance distance;


[Range(0, 10)] 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);
	distance.setValue(dist);
	Distance = dist; 
	Debug.Log (dist);



}

}

Your code looks fine and displays the correct values.
You mention triggering the sound but this code only plays on startup, either you may need a loop region on your event or use triggers to play the sound again.

Thanks a lot Cameron ! All I needed to do was to make a small loop in the timeline(FMOD). I forgot to do so because I was mainly working on the distance parameter. Thanks again! :slight_smile: