Hey there!

Just having a bit of an issue with changing a parameter using a C# script in Unity. If anyone would be able to have a look at my code and see if I’ve missed anything that would be amazing! It’s probably not the neatest as I’m still learning, but I think it should still work..

Thanks in advance!! :)


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FMOD;
using FMODUnity;

public class MusicController_Energy : MonoBehaviour {

public float energyProgress;
public GameObject uiController;
public UIController UIScript;

public FMOD.Studio.EventInstance soundeventEnergy;
public FMOD.Studio.ParameterInstance energyLevel;
public StudioEventEmitter Emitter;

public int NRG;

// Use this for initialization
void Start () {

    uiController = GameObject.Find("UIController");
    UIScript = uiController.GetComponent<UIController>();
    energyProgress = UIScript.UI_energy_angle;

    //soundeventEnergy = Emitter.EventInstance;
    soundeventEnergy = FMODUnity.RuntimeManager.CreateInstance ("event:/Music/Energy");
    soundeventEnergy.getParameter ("EnergyLevel", out energyLevel);

    //GameObject energyObj = GameObject.Find ("Energy");
    //StudioParameterTrigger Trigger = energyObj.GetComponent<StudioParameterTrigger> ();

    FMODUnity.RuntimeManager.AttachInstanceToGameObject(soundeventEnergy, GetComponent<Transform>(), GetComponent<Rigidbody>());

// Update is called once per frame
void Update () {

    energyProgress = UIScript.UI_energy_angle;

    if (energyProgress > 360) {
        //play 1
        energyLevel.setValue (1f);

        UnityEngine.Debug.Log ("1");

    else if (energyProgress > 270) {
        //play 2
        energyLevel.setValue (2f);

        UnityEngine.Debug.Log ("2");

    else if (energyProgress > 180) {
        //play 3

        energyLevel.setValue (3f);
        UnityEngine.Debug.Log ("3");


    else if (energyProgress <= 180) {
        //play 4
        energyLevel.setValue (4f);

        UnityEngine.Debug.Log ("4");


public void Play () {



  • You must to post comments
Best Answer

Worked it out!

For those looking at this with a similar issue, I needed to start the event before changing any parameters. I had the event being started by another script which loaded after all of the initial menus had cleared and the map had been generated, so this was throwing out my code.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.