Cannot change parameter on Studio Event Emitter Object.

I’ve searched high and low and everywhere and this SHOULD work. But it’s not, and I’m tearing my hair out about it.

Basically I have an emitter tied to a boat object. There’s a parameter attached to it called “boatSpeed”, basically the splashy sounds get louder the faster the boat goes. So far so good.

Here’s the event emitter attached to my boat object inside Unity.

And now for some scripts:

I declare the following variables:
private FMODUnity.StudioEventEmitter m_BoatSoundEmitter;
private float m_CurrentSpeed; // current speed of the boat.
private float m_TargetSpeed; // Target Speed of boat.
private Rigidbody m_CameraTarget;
private float speedRatio;

void Start ()
{
	m_BoatSoundEmitter = GetComponent<FMODUnity.StudioEventEmitter>();
	m_BoatSoundEmitter.SetParameter("speed", 0.0f);
}

This makes sense as at the beginning the boat is stationary.
Now every Update I call functions to move the boat:

void Update () 
{
	GetTargetSpeed();
	MoveBoat();
	TurnBoat();
	SetTrail();
	SetSound();
}

void SetSound()
{
	speedRatio = m_CurrentSpeed / m_MaxSpeed;
	m_BoatSoundEmitter.SetParameter("boatSpeed", speedRatio);
}

The only solution I can think of is to scrap using the Event Emitter inside Unity, and create an EventInstance by script and adjust that manually.

Instead of using the emitter inside Unity I instead created a script to handle the boat sound. It creates a sound instance and attached it to the Rigidbody:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BoatSound : MonoBehaviour {

[FMODUnity.EventRef]
public string m_BoatAmbience = "event:/Environment/Boat Ambience";
private BoatMover m_BoatMover;
private FMOD.Studio.EventInstance m_BoatAmbienceEvent;                //rolling event
private FMOD.Studio.ParameterInstance m_BoatSpeedParameter;    //speed param object
private float m_BoatSpeedRatio;
private Rigidbody m_BoatRigidBody;


void Start () {
	m_BoatMover = GetComponent<BoatMover>();
	m_BoatRigidBody = GetComponent<Rigidbody>();
	m_BoatAmbienceEvent = FMODUnity.RuntimeManager.CreateInstance(m_BoatAmbience);
	m_BoatAmbienceEvent.getParameter("boatSpeed", out m_BoatSpeedParameter);
	m_BoatAmbienceEvent.start();
	FMODUnity.RuntimeManager.AttachInstanceToGameObject(m_BoatAmbienceEvent, this.transform, m_BoatRigidBody);
	m_BoatSpeedParameter.setValue(0.0f);
}

void Update () {
	m_BoatSpeedRatio = m_BoatMover.m_CurrentSpeed / m_BoatMover.m_MaxSpeed;
	m_BoatSpeedParameter.setValue(m_BoatSpeedRatio);
}

void OnDestroy ()
{
	m_BoatAmbienceEvent.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
}

}

There was a bug where if the parameter checkbox was not ticked in the editor, using SetParameter would not work. This has been fixed in 1.09.08.

2 Likes