Parameter Audio Pitch Increase Effect (Like a Car) Implementation

Hi,

A solution may be instead of creating the EventInstance yourself, try using FMODUnity.StudioEventEmitter, explained further in Unity Integration | Game Components, as it will take care of a lot of preparation for us and we still get all the same functionality. The EventEmitter looks like this in Unity
image

Once you’ve added the Emitter to your object you’ll want to update your code as follows:

Code changes
private void Start()
{
	// Retrieving the EventEmitter Object
	// By using the EventEmitter Object we will also solve the problem with the sound position not updating with the car 
	emitter = GetComponent<FMODUnity.StudioEventEmitter>();

	// If there are problems with the event FMOD will log its own errors but it is always best to do your own debugging too 
	if (emitter.EventInstance.isValid() == true)
		Debug.Log("Instance is valid");
	else
		Debug.Log("Instance is not valid");
}

void Update()
{
	// Assginging your velocity
	audiovelocity = velocity;

	// A super useful FMOD debugging tool which gives insights to how functions have run
	FMOD.RESULT result;

	// Now we want to assign our parameter by the velocity 
	result = emitter.EventInstance.setParameterByName("Velocity", audiovelocity);

	if (result != FMOD.RESULT.OK)
		Debug.Log("There was an error setting parameter with result " + result);
	else
		Debug.Log("Successfully assigned parameter");
}

The meaning of each FMOD.RESULT is further explained under Core API | Common

I hope this helps!

3 Likes