# Having trouble setting parameter in script

**URL:** <https://qa.fmod.com/t/having-trouble-setting-parameter-in-script/21146>\
**Category:** Unity\
**Tags:** csharp\
**Created:** [January 23, 2024, 7:27pm UTC](https://qa.fmod.com/t/having-trouble-setting-parameter-in-script/21146 "2024-01-23T19:27:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabreese](https://avatars.discourse-cdn.com/v4/letter/g/dbc845/32.png) [@gabreese](https://qa.fmod.com/u/gabreese)\
**Post date:** [January 23, 2024, 7:27pm UTC](https://qa.fmod.com/t/having-trouble-setting-parameter-in-script/21146/1 "2024-01-23T19:27:51Z")

</div>

Im trying to set the volume of a sound effect to a parameter that changes depending on how fast one of my objects is moving (the puck specifically.) I have the parameter range within FMOD set to 0-1, however I did try changing this but it didnt work out.

script:

using System.Collections;  
using System.Collections.Generic;  
using UnityEngine;  
using FMOD.Studio;  
using FMODUnity;

public class FMODParamHandler : MonoBehaviour  
{  
//object references  
public Rigidbody2D puckRb;

```
//reference to FMODEventsHolder instance
private FMODEventsHolder eventsHolder;

//event references
public EventReference puck_HitPaddle;
public EventReference puck_BounceWall;

//event instances
private EventInstance puckHitPaddleInstance;
private EventInstance puckBounceWallInstance;

public float puckVelocityParameter;

void Start()
{
    //Initialize the reference to FMODEventsHolder
    eventsHolder = FMODEventsHolder.instance;

    //Initialize EventInstances
    puckHitPaddleInstance = FMODUnity.RuntimeManager.CreateInstance(eventsHolder.puck_HitPaddle);
    puckHitPaddleInstance = FMODUnity.RuntimeManager.CreateInstance(eventsHolder.puck_BounceWall);
}

void Update()
{
    //puckVelocity set
    Vector2 puckVelocity = puckRb.velocity;
    float puckSpeed = puckVelocity.magnitude;

    puckVelocityParameter = puckSpeed;

    puckHitPaddleInstance.setParameterByName("puckVelocity", puckSpeed);
    puckBounceWallInstance.setParameterByName("puckVelocity", puckSpeed);
}

```

}

---

<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:** [January 31, 2024, 5:24am UTC](https://qa.fmod.com/t/having-trouble-setting-parameter-in-script/21146/2 "2024-01-31T05:24:58Z")

</div>

Apologies for the delayed response.

Just to clarify, what exactly is the issue - what are you expecting to happen, and what isn’t happening? Are you events failing to play at all (there doesn’t appear to be an [`eventInstance.start()`](https://www.fmod.com/docs/2.02/api/studio-api-eventinstance.html#studio_eventinstance_start) call in your snippet), or is it that their behavior doesn’t reflect the parameter value you’re setting?
