# Scripts are not changing parameter value

**URL:** https://qa.fmod.com/t/scripts-are-not-changing-parameter-value/17470
**Category:** Unity
**Tags:** csharp, unity
**Created:** [July 22, 2021, 9:12pm UTC](https://qa.fmod.com/t/scripts-are-not-changing-parameter-value/17470 "2021-07-22T21:12:27Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Janusz](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@Janusz](https://qa.fmod.com/u/Janusz)
#### Post date: [July 22, 2021, 9:12pm UTC](https://qa.fmod.com/t/scripts-are-not-changing-parameter-value/17470/1 "2021-07-22T21:12:27Z")

</div>

Hello There!  
So I have an global parameter ‘AmbienceTime’ (local is working the same way as checked) that should send to FMOD event the hour of the day so the ambience would evolve around that, yet after few days of trying different approaches seen on forums, documentation, and after updating from 2.1.09 to 2.1.10, I have no idea why script that should update the value of that parameter is not making anything to it, anyone might have a clue what is missing here?

> System.Collections;  
> using System.Collections.Generic;  
> using UnityEngine;
> 
> public class AmbienceControl : MonoBehaviour  
> {  
> [FMODUnity.EventRef]  
> public string AmbienceEvent = “event:/Ambience/General Day Ambience/Daytime System”;  
> FMOD.Studio.EventInstance AmbienceEv;
> 
> ```
> //AudioTime will be an updated outside variable showing an hour of day - float from 0 to 24
> private float AudioTime = 8;
> 
> //works like a charm simply running an ambience event
> private void Start()
> {
> AmbienceEv = FMODUnity.RuntimeManager.CreateInstance(AmbienceEvent);
> AmbienceEv.start();
>     
> }
> 
> private void Update()
> {
> var emitter = GetComponent<FMODUnity.StudioEventEmitter>();
> 
> //this is a temporary solution to have Audiotime changed during play
> AudioTime = AudioTime + 0.01f;
> if (AudioTime > 24) { AudioTime = AudioTime - 24; }
> 
> //a line that using different metodes (SetParameterByName, ...ByID) is not making any change to parameter 
> emitter.SetParameter("AmbienceTime", AudioTime);
> 
> // shows that AudioTime works perfectly fine updating itself
> print(AudioTime);
> }
> 
> ```
> 
> }

---

<div class="post-metadata">

### Author: ![Janusz](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@Janusz](https://qa.fmod.com/u/Janusz)
#### Post date: [July 22, 2021, 11:25pm UTC](https://qa.fmod.com/t/scripts-are-not-changing-parameter-value/17470/2 "2021-07-22T23:25:49Z")

</div>

well  
after moving the script, in every way and going back to setParameterByName as it was in the very beginning somehow it managed finally to work 😕

private void Update()  
{  
AmbienceEv.setParameterByName(“AmbienceTime”, AudioTime);  
}

---

<div class="post-metadata">

### Author: ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)
#### Post date: [July 25, 2021, 10:57pm UTC](https://qa.fmod.com/t/scripts-are-not-changing-parameter-value/17470/3 "2021-07-25T22:57:37Z")

</div>

Glad you found a solution to this- It looks like the problem was due to calling `SetParameter` on the EventEmitter instead of the EventInstance. The EventEmitter version sets the initial value of the parameter whereas the EventInstance should be used for updating parameter values while it is playing.

---

<div class="post-metadata">

### Author: ![Janusz](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@Janusz](https://qa.fmod.com/u/Janusz)
#### Post date: [July 27, 2021, 9:11pm UTC](https://qa.fmod.com/t/scripts-are-not-changing-parameter-value/17470/4 "2021-07-27T21:11:20Z")

</div>

Hi, thanks for the tip, I guess I will make use of that in the future 👍

Anyway, there is chance I was doing every approach that I found on the web back then bad, or it was some bug between FMOD and unity but after few days It was going fluently for me till the end of project 😆 I wish there would be some clear description for that in some FMOD tutorials, as learning those stuff as I did was a massacre and I would say that I’m in comfort position of someone that quite understand coding (especially that most tutorials reflect scripting FMOD before 2.0 lol)

---

<div class="post-metadata">

### Author: ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)
#### Post date: [July 27, 2021, 11:27pm UTC](https://qa.fmod.com/t/scripts-are-not-changing-parameter-value/17470/5 "2021-07-27T23:27:30Z")

</div>

I think the [Karting Tutorial](https://www.fmod.com/resources/documentation-unity?version=2.02&page=integration-tutorial.html) covers the basics of setting parameters and is a good one to check out if you haven’t already- though it sounds like you’ve gotten your head around it now. You are right though, we don’t have any youtube tutorials post version 1. I’ll see what’s going on there since we’ve dropped support for everything below 2.0

---

<div class="post-metadata">

### Author: ![msyoung2012](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/msyoung2012/32/3551_2.png) [@msyoung2012](https://qa.fmod.com/u/msyoung2012)
#### Post date: [May 21, 2022, 10:36pm UTC](https://qa.fmod.com/t/scripts-are-not-changing-parameter-value/17470/6 "2022-05-21T22:36:40Z")

</div>

This is the exact method proposed in the documentation in the kart example (calling SetParamater on the emitter vs the Instance to provide continuous updates). This should be updated in the docs.

---

<div class="post-metadata">

### Author: ![msyoung2012](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/msyoung2012/32/3551_2.png) [@msyoung2012](https://qa.fmod.com/u/msyoung2012)
#### Post date: [May 21, 2022, 10:44pm UTC](https://qa.fmod.com/t/scripts-are-not-changing-parameter-value/17470/7 "2022-05-21T22:44:28Z")

</div>

![Screen Shot 2022-05-21 at 6.43.34 PM](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/5/59b88064072fc5814c6a196d66f6e7c81c710c39.png)  
In fact, the documentation explicitly says the exact opposite - that using the event is the correct way to handle updates.

---

<div class="post-metadata">

### Author: ![brownadm](https://avatars.discourse-cdn.com/v4/letter/b/5daacb/32.png) [@brownadm](https://qa.fmod.com/u/brownadm)
#### Post date: [May 23, 2022, 5:35am UTC](https://qa.fmod.com/t/scripts-are-not-changing-parameter-value/17470/8 "2022-05-23T05:35:16Z")

</div>

I had a very similar issue, which remains unresolved. Code in Unity is all passing to the functions and everything, but there’s some kind of disconnect between Unity and FMOD. setParameterByName is working on some scripts but not others in the same scene. Even in the same script, which changes a single parameter value twice, one of the changes is happening, and the other isn’t. Scratching my head over here. I’m using FMOD 2.02.05 and Unity 2021.3.2f1 (LTS).

I, too, am disappointed by the lack of updated information in the docs, and across the web. It seems like most help I can find is outdated.

---

<div class="post-metadata">

### Author: ![brownadm](https://avatars.discourse-cdn.com/v4/letter/b/5daacb/32.png) [@brownadm](https://qa.fmod.com/u/brownadm)
#### Post date: [May 23, 2022, 5:45am UTC](https://qa.fmod.com/t/scripts-are-not-changing-parameter-value/17470/9 "2022-05-23T05:45:14Z")

</div>

I’ll post a forum question soon, but it was very simple. I had Global Parameters in FMOD, and I had to do something like:

void Awake()  
{  
FMODUnity.RuntimeManager.StudioSystem.setParameterByName(“EnterBossFight”, 1);  
}

void Start  
{  
FMODUnity.RuntimeManager.StudioSystem.setParameterByName(“EnterBossFight”, 0);  
}

I had tried every permutation of that possible, too much to type now. I also tried to do the same via SetParameter on an emitter, which works on another project I’m doing concurrently…

The only difference between my two projects right now is that one is using Unity 2021.3.2f1, and the other is using an older release. So, I’m guessing there’s a bug with FMOD/Unity right now?

Typing on my phone, so I may have small errors (autocorrects) in the code, but the point is, it’s not a difficult function. Just setting a value of 1, and then 0.

---

<div class="post-metadata">

### Author: ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)
#### Post date: [May 24, 2022, 6:51am UTC](https://qa.fmod.com/t/scripts-are-not-changing-parameter-value/17470/10 "2022-05-24T06:51:58Z")

</div>

Apologies for the confusion- the problem appears to have been because you cannot set a global parameter using a Studio Event Emitter. I have passed a task onto the Dev team to address this issue.

The documented behaviour of calling `SetParameter` on an Event Emitter to change the parameter value of the Event Emitter’s event is correct.  
@msyoung2012 Are you having any issues with setting parameter values that I can help you with?  
@brownadm There could be a bug here which would be a separate issue. If you could please create a new forum post with your problem described in detail then we can help you figure out what might be going wrong.
