# Can't Access InBuilt Speed Parameter from API

**URL:** <https://qa.fmod.com/t/cant-access-inbuilt-speed-parameter-from-api/19509>\
**Category:** FMOD Engine\
**Tags:** unity, csharp\
**Created:** [November 12, 2022, 12:35pm UTC](https://qa.fmod.com/t/cant-access-inbuilt-speed-parameter-from-api/19509 "2022-11-12T12:35:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![NiccoloGranieri](https://avatars.discourse-cdn.com/v4/letter/n/6de8d8/32.png) [@NiccoloGranieri](https://qa.fmod.com/u/NiccoloGranieri)\
**Post date:** [November 12, 2022, 12:35pm UTC](https://qa.fmod.com/t/cant-access-inbuilt-speed-parameter-from-api/19509/1 "2022-11-12T12:35:54Z")

</div>

Hello, I am writing following [this](https://qa.fmod.com/t/accessing-inbuilt-parameters-via-api/19487/6) discussion where I was able with some help to get the InBuilt parameters in a C# script.

I was able to successfully get all the inbuilt parameters _except_ the Speed parameter (both relative and absolute).

I have scoured the forum but I wasn’t able to solve the issue even though I _think_ I have followed every suggestion given so far. Here is my setup:

1. I have been moving a Rigidbody cube both by animating it (as suggested [here](https://qa.fmod.com/t/speed-built-in-parameter-question/14510/2)) and by using the following script:

```auto
public class LFO_Speed : MonoBehaviour
{
    Rigidbody m_Rigidbody;
    public float m_Speed = 5f;

    void Start()
    {
        m_Rigidbody = GetComponent<Rigidbody>();
    }

    void Update()
    {
        Vector3 m_Input = new Vector3(1, 0, 0);
        m_Rigidbody.MovePosition(transform.position + m_Input * Time.deltaTime * m_Speed);
    }
}

```

1. On the same cube, I am then loading the script that is meant to retrieve the Speed Inbuilt parameter, as successfully done for every other inbuilt parameter.

```auto
public class Velocita_SEND : MonoBehaviour
{
    float finalParameterValue;
    public FMODUnity.EventReference eventRef;
    FMOD.Studio.EventInstance eventInst;

    void Start()
    {
        eventInst = FMODUnity.RuntimeManager.CreateInstance(eventRef);
    }

    void Update()
    {
        eventInst.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject));
        eventInst.start();
        eventInst.release();
        eventInst.getParameterByName("Speed", out _, out finalParameterValue);

        Debug.Log(finalParameterValue);
    }
}

```

1. I am loading an FMOD 3D Template event, with a loop region on the empty timeline, and a Speed (Absolute) inbuilt parameter called Speed. I have also tried the Speed (Relative) and I have obtained the same results.

I get 0 speed no matter how I move the cube (animation or Rigidbody.MovePosition) and I can’t seem to get it to work.

_However_, if I do the following:

- Add a sound to the Speed parameter sheet

- Load the event on the cube using a FMOD Studio Event Emitter

- Move the cube with the script rather than animating it

- Set the Rigidbody to be _kinematic_

I can get the event to play, and the speed of the rigid body to affect the sound. So the event _is_ working, the speed parameter _is_ being affected, and albeit some glitches, everything is working as it should.

Could it be that the Speed inbuilt parameter is bugged or am I doing something wrong?

---

<div class="post-metadata">

**Author:** ![NiccoloGranieri](https://avatars.discourse-cdn.com/v4/letter/n/6de8d8/32.png) [@NiccoloGranieri](https://qa.fmod.com/u/NiccoloGranieri)\
**Post date:** [November 15, 2022, 5:25pm UTC](https://qa.fmod.com/t/cant-access-inbuilt-speed-parameter-from-api/19509/3 "2022-11-15T17:25:38Z")

</div>

Solution provided by Alessandro Fama on [Twitter](https://twitter.com/alexzen_/status/1592561257441538050?s=20&t=PPtSw-tsKT4ywZxohePejQ): You also need to pass the rigidbody to the helper function To3DAttributes, otherwise the velocity vector of the 3D attributes struct will not be filled.

As seen [here](https://fmod.com/docs/2.02/unity/api-runtimeutils.html#to3dattributes) to get the velocity vector we also need to specify the Rigidbody in the To3DAttributes helper function.

```auto
static FMOD.ATTRIBUTES_3D To3DAttributes(
  GameObject go,
  Rigidbody rigidbody = null
);

```

So the line of code above:

```auto
eventInst.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject));

```

becomes:

```auto
eventInst.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject, rigidbody));

```

assuming that rigidbody is a Rigidbody component.
