# Can't get parameterValue to work

**URL:** <https://qa.fmod.com/t/cant-get-parametervalue-to-work/20207>\
**Category:** Unity\
**Tags:** unity, csharp\
**Created:** [May 9, 2023, 9:16pm UTC](https://qa.fmod.com/t/cant-get-parametervalue-to-work/20207 "2023-05-09T21:16:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rondinarn](https://avatars.discourse-cdn.com/v4/letter/r/ad7895/32.png) [@Rondinarn](https://qa.fmod.com/u/Rondinarn)\
**Post date:** [May 9, 2023, 9:16pm UTC](https://qa.fmod.com/t/cant-get-parametervalue-to-work/20207/1 "2023-05-09T21:16:11Z")

</div>

So I am having some trouble with a simple parameterScript I made for unity using fmod. Whenever the player hits a triggerbox with this script and the right values filled in it should change a parameter in Fmod. Weirdly enough it works with the first trigger box but not the 2nd. Do you have any ideas what might be the problem?

Here is my script :  
using UnityEngine;  
using FMODUnity;  
using FMOD.Studio;

public class ParameterScriptFmod : MonoBehaviour  
{

```
[SerializeField] private string playerTag = "Player";
[SerializeField] private string parameterName;
[SerializeField] private float parameterValue;
[SerializeField] private string fmodEventPath;

private EventInstance fmodEventInstance;

private void Awake()
{
    fmodEventInstance = RuntimeManager.CreateInstance(fmodEventPath);
}

private void OnTriggerEnter2D(Collider2D other)
{
    if (other.CompareTag(playerTag))
    {
        Debug.Log("ParamChange");
        fmodEventInstance.setParameterByName(parameterName, parameterValue);
        DestroyAudioTrigger();
        Debug.Log("ParamChange");

    }
}

private void Start()
{
    fmodEventInstance.start();
  

}

private void OnDestroy()
{
    // Release the FMOD event instance when the game object is destroyed
    fmodEventInstance.release();
}

void DestroyAudioTrigger()
{
    Destroy(gameObject);
}

```

}

 ![Skärmavbild 2023-05-09 kl. 23.10.58](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/b/b81e905a0be409ad4b370c30993b9a7d235ca5d9.jpeg)

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [May 10, 2023, 5:59am UTC](https://qa.fmod.com/t/cant-get-parametervalue-to-work/20207/2 "2023-05-10T05:59:52Z")

</div>

Hi,

What version of the FMOD integration are you using?

I’d suggest using `FMOD.RESULT` to check the success of FMOD function calls as it aids in debugging issues like this. The full error explanation list can be found here: [FMOD API | Core API Reference - Common](https://fmod.com/docs/2.02/api/core-api-common.html#fmod_result). You’d add it to the code like so:

```auto
private void OnTriggerEnter2D(Collider2D other)
{
    if (other.CompareTag(playerTag))
    {
        Debug.Log("ParamChange");
        FMOD.RESULT result = fmodEventInstance.setParameterByName(parameterName, parameterValue);
        if (result != FMOD.RESULT.OK)
        {
            Debug.Log(result.ToString());
        }
        DestroyAudioTrigger();
        Debug.Log("ParamChange");

    }
}

```

Another option is changing the logging level in the FMOD integration settings:  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/0/03e8c7388561e4f13d88e8c709a7be181c511c11.png)  
`Warning` is a good level to make sure nothing is going missed.

Let me know if that shines any light on what is going on!
