Get Vive/ Oculus Touch battery status?
Hi! Is it possible in Unity to get the current amount of remaining battery percentage per left/ right VR controller? (I see there's SystemInfo.batteryLevel but that presumably relates to e.g. a mobile device's battery.) Thanks!
Answer by Klarzahs · Mar 06, 2019 at 10:41 AM
Even though this question was asked a long time ago, I'll still provide the answer, in case anyone else is searching for it. In short: Yes, you can.
It is just not made "readily available", it's hidden in the API
You can use the ETrackedDeviceProperty for each of the controller or HMD, which describes the different information that is tracked for each device. The enum property you'd be looking for is called Prop_DeviceBatteryPercentage_Float.
You can query this property by using
ETrackedPropertyError err = new ETrackedPropertyError();
float f = OpenVR.System.GetFloatTrackedDeviceProperty((uint)trackedObj.index,ETrackedDeviceProperty.Prop_DeviceBatteryPercentage_Float, ref err);
if (err == ETrackedPropertyError.TrackedProp_Success) {
Debug.Log("Battery level: " + f);
}else{
Debug.LogError("Cannot read batterylevel: " + err.ToString());
}
where trackedObj is your SteamVR_TrackedObject, representing a controller. The returned value will range between 0 and 1.
Do you know if this works for oculus controllers? I can't get the battery percentage for oculus
Your answer
Follow this Question
Related Questions
Vector3.Angle is wrong 1 Answer
VR Fingers animation 0 Answers
Printing Console Errors to screen in VR build 0 Answers
[VR] How to make an active rigidbody work in VR, similar to how Nimsony or Boneworks does it? 1 Answer
VR Scene Rotation on Build 0 Answers