Hi this may seem similar to a previous post but it’s actually completely different. I’m also a noob programmer (if that) and am wondering how I get the velocity of a Rigidbody attached to the camera. It’s to send 3D listener info to FMOD.
I’ve attached a Rididbody and a script to the camera. This is all the relevant stuff in the script.
..........
private FMOD.VECTOR pos;
private FMOD.VECTOR vel;
private FMOD.VECTOR forward;
private int listener = 0;
private FMOD.VECTOR up;
private Rigidbody me;
public string SoundController = "SoundControl";
void Start () {
me = GetComponent<Rigidbody>();
..........
void Update () {
//Debug.Log("I am ALIVE");
pos = VectorConvert(this.transform.position);
//Debug.Log("Playa Position is now " + pos.x + ", " + pos.y + ", "+ pos.z);
vel = VectorConvert(me.velocity);
//Debug.Log("Viewer speed should be " + me.velocity.magnitude);
forward = VectorConvert(this.transform.forward);
up = VectorConvert(this.transform.up);
FMOD.RESULT result = eventsystem.set3DListenerAttributes(listener, ref pos, ref vel, ref forward, ref up);
//result = system.set3DListenerAttributes(listener, ref pos, ref vel, ref forward, ref up);
ERRCHECK(result);
FMOD.VECTOR RealPos = VectorConvert(Vector3.zero);
eventsystem.get3DListenerAttributes(listener, ref RealPos, ref vel, ref forward, ref up);
.......
the (…) bits contain FMODy stuff that aren’t really important. When I use the debuglog below the vel = VectorConvert(me.velocity) I just get 0 on every update even though the camera is moving to follow my player.
Any ideas?