Hello! I’ve got a BB-like character that I’m trying to make, like, audio pitches up the faster it’s going and it pitches back down if it goes slower. In the FMOD event, I have it ranged from 0-50, the range of the character’s velocity, with the audio changing the higher the velocity is:
It works in FMOD when I drag the slider while it’s playing.
The script I created for implementation is below. It’s inside the movement logic script, so I removed the stuff that is filler for this forum, like WASD movement and all that:
public class MovementLogic : MonoBehaviour
{
//Acceleration BB
private FMOD.Studio.EventInstance BBCar;
public FMODUnity.EventReference fmodEvent;
private float test;
[SerializeField]
[Range(0f, 50f)]
private float acceleration, audiovelocity;
public float velocity;
void Start()
{
BBCar = FMODUnity.RuntimeManager.CreateInstance(fmodEvent);
BBCar.start();
}
void Update()
{
audiovelocity = velocity;
BBCar.setParameterByName("Velocity", audiovelocity);
BBCar.getParameterByName("Velocity", out test);
Debug.Log(test);
}
}
Velocity was already a variable in the script created for actual movement speed, I didn’t want to use it for also the FMOD velocity, just to be safe, so I created ‘audiovelocity’ and assigned velocity to that variable. ‘Acceleration’ is a parameter that I made for FMOD too, but I wanted to implement it first to see if the velocity would work. I wasn’t having much luck implementing it, so I created a gerParameter after setParameter to see if it was getting anything, and it was. Regardless, no sound occurs, even when the slider moves in Unity and I get Debug logs like crazy showing that it is getting the parameter.
Any help would be appreciated, I figured this was the logical way to implement it but I guess not.
EDIT 1: I’ve been working on it all day, and in-the editor it still doesn’t work. But when I build the game, it will work, but only within the radius of where the character starts. So. That’s odd.