Hello, I am writing following this 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:
- I have been moving a Rigidbody cube both by animating it (as suggested here) and by using the following script:
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);
}
}
- 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.
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);
}
}
- 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?