0
0

Hello,

I’m attempting to change an event parameter from script using setParameterValue.

So far I can confirm that the script is calling, but the parameter does not appear to be changing (the expected change to the event is not occurring). I’m not producing any FMOD_DEBUG error messages.

Am I using the correct method for changing an event parameter? Is there a way for me to better debug the script call is being received correctly?

  • You must to post comments
0
0

[quote="dnishimura":3fq96yke]
When you assign the event to the Music field, you’re not referencing the FMOD Emitter, but you’re creating a new instance of that sound.
To fix this, remove the FMOD_STudioEvent, create a Start method on your AMBController class, and call Music.start().[/quote:3fq96yke]

Thank you for responding, and forgive my ignorance, I don’t claim to be a well-versed programmer.

When you say remove the FMOD_StudioEvent, are you referring to [code:3fq96yke]FMOD.Studio.EventInstance Music;[/code:3fq96yke] or [code:3fq96yke]Music = FMOD_StudioSystem.instance.GetEvent ("event:/BattleMusic");[/code:3fq96yke]?

I thought you were referring to [code:3fq96yke]Music = FMOD_StudioSystem.instance.GetEvent ("event: /BattleMusic");[/code:3fq96yke] but then Music.start(); returns null in the Start() function. So I tried removing FMOD.Studio.EventInstance Music; but then I am told that "Music" does not exist in its current context with the line [code:3fq96yke]Music = FMOD_StudioSystem.instance.GetEvent ("event: /BattleMusic");[/code:3fq96yke].

Could you be more specific? I thought there already was a Start() method, or is that just a regular function? Now that you’ve pointed it out to me, I understand that I’m not referencing the FMOD Emitter, and I appreciate that.

So how do I reference it instead of creating a new instance? Or should I not use the Emitter and just create a new instance? I did add Music.start() but I am still unclear on how to define my Music variable so that it is referencing the FMOD_Studio Event Emitter.

Thank you again, I appreciate your patience greatly.

  • You must to post comments
0
0

Hey! I got it working! Thank you so much! I didn’t have to delete any line though, I just added Music.start(); in between "Music = FMOD_Studio.instance.GetEvent("event:/BattleMusic");" and "Music.getParameter("Combat", out combatVal);" and it WORKED! I also had to make sure "Start Event on Awake" was unchecked on the FMOD_Studio Event Emitter Component.

Thank you so much!

  • You must to post comments
0
0

Hi! I’m having this exact issue in that I am trying to change a parameter set in FMOD Studio from within Unity. When I’m in FMOD Studio, I have a series of loop regions and transition regions set up and altering the parameter while the event is playing produces the desired event behavior. To provide as much info as I can, here’s a screenshot of my FMOD Studio event:

[url:3lwopv77]http://i.imgur.com/3jxhvFj.png[/url:3lwopv77]

I attached the FMOD_Studio Event Emitter script to an Empty Game Object and the only other component the object has besides a Transform is the script I’m trying to use to control the Combat parameter of my event, named AMBController.

[img:3lwopv77]http://i.imgur.com/h2Kvptc.png[/img:3lwopv77]

It’s a very simple script:

[code:3lwopv77]using UnityEngine;
using System.Collections;

public class AMBController : MonoBehaviour {

public bool combat;

FMOD.Studio.EventInstance Music;
FMOD.Studio.ParameterInstance combatVal;

// Use this for initialization
void Start () {
    combat = false;

    Music = FMOD_StudioSystem.instance.GetEvent ("event:/BattleMusic");
    Music.getParameter("Combat", out combatVal);
}

// Update is called once per frame
void Update () {
    bool toggle = Input.GetKeyUp (KeyCode.Space);

    if (toggle) {
        if (!combat) {
            combat = true;
            combatVal.setValue(0.9f);
        }
        else if (combat) {
            combat = false;
            combatVal.setValue(0.1f);
        }
    }
}

}[/code:3lwopv77]

My "To Combat_On" transition region is set to trigger whenever the Combat parameter is between 0.58 and 1.0; the "To Combat_End" transition region is set to trigger when the Combat parameter is between 0.0 and 0.47, so using 0.1f and 0.9f are relatively arbitrary values for triggering the transition regions in my BattleMusic event.

When I begin playing the scene, I hear the BattleMusic event playing, but when I hit the space key, the event does not transition at all to the Combat_On marker in my FMOD event, even though I can see that the public bool combat is toggling on and off in Unity’s Inspector window.

Please help? I’m not getting any errors in Unity’s console at all and I’m quite stumped.

-Mike Patterson

  • You must to post comments
0
0

Hi MikePatterson,

I believe you missed one little thing.
When you assign the event to the Music field, you’re not referencing the FMOD Emitter, but you’re creating a new instance of that sound.
To fix this, remove the FMOD_STudioEvent, create a Start method on your AMBController class, and call Music.start().

  • You must to post comments
0
0

The way I do is something like this:

[code:1sf38ifp]public FMODAsset SoundAsset; //Define this at the editor

EventInstance soundInstance;
ParameterInstance paramInstance;

public void CreateSoundInstance()
{
soundInstance = FMOD_StudioSystem.instance.getEvent(SoundAsset);
soundInstance.getParameter ("MyParam", out paramInstance);
}

public void SetValue(float newValue)
{
paramInstance.setValue (newValue);
}[/code:1sf38ifp]

Have you tested adjusting the parameter at the FMOD Studio? Did it work there?

  • You must to post comments
0
0

Thank you so much, dnishimura!

I was forgetting to prefix my "paramInstance" argument with "out" inside getParameter.

  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.