Jump to content

Getting Controller velocity for Oculus


Recommended Posts

This must be so straightforward, but I just can't get it to work. How can I get the controller velocity on the Oculus Quest 2? I know that for SteamVR it works using the SteamVRBehaviourPose component.

I have a standard VR CameraRig with RightHand and LeftHand. Both have a VivePoseTracker (Transforms) on them and a rigidbody. When I print the Rigidbody.Velocity it always shows (0,0,0). I figured, maybe I should use the ViveRigidPoseTracker (Rigidbody), but then my controllers were not tracked at all, so I reverted that.

I checked the scripts to see if it might be similar to the problem with button presses, but there are no switches for Oculus_Quest in both PoseTracker scripts.

So I hope someone can point me to the soution.

The context is that I want to throw a ball. I made an alternative solution using ViveColliders and BasicGrabbable. That works, but the velocity there is off as well. The trajectory of the ball after releasing the trigger looks like the ball is extremely heavy. It flies only only about 2 meters, where it should fly for 20 -30 meters. So it looks like the velocity transferred to the ball is a lot slower than the velocity of the controller. The mass of the ball is 0.195 kg, so it is not extremely heavy. In the option decribed above I can use a multiplication factor to increase the velocity (I do that in the SteamVR version as well), but with BasicGrabbable I can't find such a work-around.


Link to comment
Share on other sites

Thanks for the reactions.

@chengnayI am using
Unity 2019.4.18f1
VIU version for Oculus Android device.
The Oculus integration I can't find. Checked the folder in the hierarchy for a version log, checked the Oculus item in the editor menu, checked one of the scripts but nowhere is a vesion number. The only thing  can find the is Oculus XR Package, which is version 1.5.0

@lawwong Great, that works now!

Link to comment
Share on other sites

@jboss If you import Oculus Integration from Asset Store, probably the version shows in Asset Store will be your final version.

Anyway, I will just use the latest version from Asset Store and try, thanks!


UPDATE: You can also use below method to get velocity that provided by Oculus SDK.

public ViveRoleProperty role = ViveRoleProperty.New(); or ViveRoleProperty.New(HandRole.RightHand);

var deviceState = VRModule.GetCurrentDeviceState(role.GetDeviceIndex());

Debug.Log("velocity: " + deviceState.velocity);

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...