VR: get controller velocity

Hey there,

I am currently loosing my mind about something that I thought would be super simple. I want to get the velocity vector (or position vector) of my Oculus Quest 2 controller so I can use it in my code. Currently I am trying to do this with XRNodeStates (Unity - Scripting API: XR.XRNodeState.TryGetVelocity). However I just can’t figure out a way how to make it work - I am a complete beginner sorry.

What would the code be for this? If you could help me out that would be great!

All the best,

It works for me. I found it there:

using UnityEngine;

using UnityEngine.XR;

using UnityEngine.XR.Interaction.Toolkit;

public class ControllerVelocity : MonoBehaviour

    InputDevice LeftControllerDevice;
InputDevice RightControllerDevice;
Vector3 LeftControllerVelocity;
Vector3 RightControllerVelocity;

void Start()
	LeftControllerDevice = InputDevices.GetDeviceAtXRNode(XRNode.LeftHand);
	RightControllerDevice = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);

void Update()

	LeftControllerDevice.TryGetFeatureValue(CommonUsages.deviceVelocity, out LeftControllerVelocity);
	RightControllerDevice.TryGetFeatureValue(CommonUsages.deviceVelocity, out RightControllerVelocity);