# StudioEventEmitter.SetParameter() only works in Update()

**URL:** <https://qa.fmod.com/t/studioeventemitter-setparameter-only-works-in-update/17527>\
**Category:** Unity\
**Created:** [August 4, 2021, 6:12pm UTC](https://qa.fmod.com/t/studioeventemitter-setparameter-only-works-in-update/17527 "2021-08-04T18:12:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicholsp](https://avatars.discourse-cdn.com/v4/letter/n/6de8d8/32.png) [@nicholsp](https://qa.fmod.com/u/nicholsp)\
**Post date:** [August 4, 2021, 6:12pm UTC](https://qa.fmod.com/t/studioeventemitter-setparameter-only-works-in-update/17527/1 "2021-08-04T18:12:05Z")

</div>

Hello, I’ve used this method a lot in a previous project, but now it doesn’t seem to be working. Actually it does work if I use StudioEventEmitter.SetParameter(…) in my Update() function, but it doesn’t work if I use it in any one-time calls.

For instance, I want to modulate an impact sound in OnCollisionEnter() like this:

```auto
using UnityEngine;
using FMODUnity;

public class Drum : MonoBehaviour
{
    public float minImpact = .05f;
    public float impactVelocityThreshold = 20f;
    public StudioEventEmitter drumSound;

    private void OnCollisionEnter(Collision collision)
    {
        float hitForce = Mathf.Clamp01(collision.relativeVelocity.sqrMagnitude / impactVelocityThreshold);
        //Debug.Log("Hit Drum. Force = " + hitForce);
        if (hitForce > minImpact)
        {
            drumSound.SetParameter("HitForce", hitForce);
            drumSound.Play();
        }
    }

```

The code doesn’t return any errors but it doesn’t effect the sound either, it doesn’t seem like the parameter is being set. (I’ve double checked the spelling and the parameter’s automation curves.) Any idea what I should check for or if I should use a different method? Thanks so much for your time 🙂

---

<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:** [August 5, 2021, 1:45am UTC](https://qa.fmod.com/t/studioeventemitter-setparameter-only-works-in-update/17527/2 "2021-08-05T01:45:16Z")

</div>

I think calling play is resetting to the initial StudioEventEmitter parameter value.  
This might be a bug, or at least confusing behaviour, so I’ll raise with the Dev team- especially if you have found that it didn’t used to behave in this way.  
Try swapping around the `SetParameter` and `Play` calls and let me know if it starts working properly, i.e

```auto
if (hitForce > minImpact)
{
    drumSound.Play();
    drumSound.SetParameter("HitForce", hitForce);
}

```

---

<div class="post-metadata">

**Author:** ![nicholsp](https://avatars.discourse-cdn.com/v4/letter/n/6de8d8/32.png) [@nicholsp](https://qa.fmod.com/u/nicholsp)\
**Post date:** [August 5, 2021, 6:19pm UTC](https://qa.fmod.com/t/studioeventemitter-setparameter-only-works-in-update/17527/3 "2021-08-05T18:19:28Z")

</div>

Oh nice! Yeah that works. Thanks for getting back to me so quickly!
