# Setting a Parameter FMOD 2.0 / Unity

**URL:** https://qa.fmod.com/t/setting-a-parameter-fmod-2-0-unity/14605
**Category:** FMOD Engine
**Created:** [April 23, 2019, 12:30pm UTC](https://qa.fmod.com/t/setting-a-parameter-fmod-2-0-unity/14605 "2019-04-23T12:30:29Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Bence](https://avatars.discourse-cdn.com/v4/letter/b/5e9695/32.png) [@Bence](https://qa.fmod.com/u/Bence)
#### Post date: [April 23, 2019, 12:30pm UTC](https://qa.fmod.com/t/setting-a-parameter-fmod-2-0-unity/14605/1 "2019-04-23T12:30:29Z")

</div>

Hey guys,

I’m still rather new to FMOD especially FMOD 2.0. What I’m trying to do is quiet simple I just don’t get it to run with FMOD 2.0 an the new Parameter API.

I basically want to create a dynamic acceleration sound using Unity (2018.3.12f1) and FMOD (2.0). The spacebar will be the trigger to accelerate.

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

public class Acceleration : MonoBehaviour
{
// Start is called before the first frame update

float initialVelocity = 0.0f;
float finalVelocity = 100.0f;
float currentVelocity = 0.0f;
float acceleration = 10.0f;
float deceleration = 5.0f;

bool ignoreseekspeed = false;
/* [FMODUnity.EventRef]
 public FMOD.Studio.EventInstance Noise; */

// Update is called once per frame
void Update()
{
    if(Input.GetKey("space"))
    {
        currentVelocity = currentVelocity + (acceleration * Time.deltaTime);
    }
    else
    {
        currentVelocity = currentVelocity - (deceleration * Time.deltaTime);
    }

    currentVelocity = Mathf.Clamp(currentVelocity, initialVelocity, finalVelocity);

    print("ArrowPressed" + currentVelocity);

    RESULT Studio.EventInstance.setParameterByName("Velocity", currentVelocity, ignoreseekspeed);
    
}

}

```

Somehow it says that the last line “Studio.EventInstance.setParameterByName(…)” is not available in the current context.  
Maybe I’m just misunderstanding the new Parameter API somehow. I’d be glad if someone can help me out with it.

Cheers!

---

<div class="post-metadata">

### Author: ![cameron-fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/cameron-fmod/32/261_2.png) [@cameron-fmod](https://qa.fmod.com/u/cameron-fmod)
#### Post date: [April 29, 2019, 11:35pm UTC](https://qa.fmod.com/t/setting-a-parameter-fmod-2-0-unity/14605/2 "2019-04-29T23:35:38Z")

</div>

You need to call `setParameterByName` on an [Event Instance](https://www.fmod.com/resources/documentation-api?version=2.0&page=studio-api-eventinstance.html), not using the namespace.

For example:

```auto
[FMODUnity.EventRef]
public string eventName = "";
FMOD.Studio.EventInstance instance;

Start
{
    instance = FMODUnity.Runtimemanager.CreateInstance(eventName);
    ...
    instance.setParameterByName(...);
}

```
