# Changing Paremeters in Unity From Code

**URL:** <https://qa.fmod.com/t/changing-paremeters-in-unity-from-code/21495>\
**Category:** Unity\
**Tags:** unity, csharp\
**Created:** [April 13, 2024, 7:15am UTC](https://qa.fmod.com/t/changing-paremeters-in-unity-from-code/21495 "2024-04-13T07:15:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sportsy](https://avatars.discourse-cdn.com/v4/letter/s/a4c791/32.png) [@Sportsy](https://qa.fmod.com/u/Sportsy)\
**Post date:** [April 13, 2024, 7:15am UTC](https://qa.fmod.com/t/changing-paremeters-in-unity-from-code/21495/1 "2024-04-13T07:15:45Z")

</div>

Hi!  
I’m new with FMOD and I’m still working my way around the tool and I ran into a problem I haven’t be able to fix, Im trying to change my parameters with the StudioParameterTrigger from the code

The paramater is supposed to change the panning of my event

```auto
 if (GameObject.FindWithTag("Monster") == null)
 {
     spawnedMonster = Instantiate(monster, posicionElegida[posicionActual], Quaternion.identity);
     emitter = spawnedMonster.GetComponent<StudioEventEmitter>();
     paramTrigger = spawnedMonster.GetComponent<StudioParameterTrigger>();
 }

 paramTrigger.TriggerParameters();
 emitter.Play();

```

The game object has both the emitter and the parameter trigger assigned

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/d/d756d8668c1fe170a36b126dcc627a8e77897194.png)

but no matter from where or how I call the trigger parameters it just doesnt change

I have also tried `emitter.SetParameter("Testing" -1f)` and `emitter.EventInstance.setParameterByName("Testing", -1f)` both sound exactly as if the parameter value was 0 (default value)

---

<div class="post-metadata">

**Author:** ![Leah\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/leah_fmod/32/3685_2.png) [@Leah\_FMOD](https://qa.fmod.com/u/Leah_FMOD)\
**Post date:** [April 17, 2024, 4:06am UTC](https://qa.fmod.com/t/changing-paremeters-in-unity-from-code/21495/2 "2024-04-17T04:06:13Z")

</div>

> [@Sportsy](#):
>
> ```auto
> paramTrigger.TriggerParameters();
> emitter.Play();
> 
> ```

The issue is with the ordering of these two lines of code. The Studio Event Emitter’s underlying event instance isn’t created until `emitter.Play()` is called, so in this case, the parameters that are being triggered aren’t applied because the event instance doesn’t exist yet. If you swap the order of the two, you should get the desired behavior.
