Forum Discussion
Haraden994
4 years agoExplorer
How to keep hands displayed when tracking is lost?
Hello, I'm developing a game for my master thesis with Unity using oculus hand tracking, I need to keep hands displayed and just "freeze" them when the tracking is lost. Is there a way to do so?
I found the GetHandState method in the OVRHand.cs script, I tried to comment the section that checks if the tracking is lost to see what happens but the hands still disappear when tracking is lost.
- Anonymous4 years ago
It's something I'd wanted to implement for a while and I got it working yesterday. It wasn't too bad. I believe there's an example of using the OVRCustomSkeleton script in the sample framework.
So in my implementation I have a prefab with OVRHand, OVRCustomSkeleton and my "HandController" script that instantiates the rendered hand and updates the positions of the bones of the rendered hand in LateUpdate.
In the Start of the HandController I get the Bones from the OVRCustomSkeleton (may have to wait a frame before the bone Count != 0) and match each bone transform from the skeleton to a transform in the instantiated hand (an array of (Transform,Transform) tuples).
Then in LateUpdate I iterate over that array and set the localPosition and localRotation of the rendered hand transform to the localPosition and localRotation of the skeleton transform.
I recommend using OVRHand.IsDataHighConfidence instead of OVRHand.IsTracked to decided whether to update the transforms, because the last few frames before tracking is lost can send the hand to completely random positions/poses.
4 Replies
- Anonymous
Take a look at the app Cubism in the Quest store. I think it has the best hand tracking implementation I've seen.
I believe what they are doing is copying the bone positions/rotations coming from an OVRCustomSkeleton component (transforms that aren't being rendered) to a second (rendered) mesh. When hand tracking is lost they stop updating the transforms and that leaves the rendered mesh hanging in space at the position of the last good tracking.
- Haraden994Explorer
I'll do that, thanks. So do you think is better to create new code from scratch instead of editing the Oculus scripts? Because stopping the hand from having the usual "tracking lost" behaviour should be simple, theoretically 😅
- Anonymous
It's something I'd wanted to implement for a while and I got it working yesterday. It wasn't too bad. I believe there's an example of using the OVRCustomSkeleton script in the sample framework.
So in my implementation I have a prefab with OVRHand, OVRCustomSkeleton and my "HandController" script that instantiates the rendered hand and updates the positions of the bones of the rendered hand in LateUpdate.
In the Start of the HandController I get the Bones from the OVRCustomSkeleton (may have to wait a frame before the bone Count != 0) and match each bone transform from the skeleton to a transform in the instantiated hand (an array of (Transform,Transform) tuples).
Then in LateUpdate I iterate over that array and set the localPosition and localRotation of the rendered hand transform to the localPosition and localRotation of the skeleton transform.
I recommend using OVRHand.IsDataHighConfidence instead of OVRHand.IsTracked to decided whether to update the transforms, because the last few frames before tracking is lost can send the hand to completely random positions/poses.
- Haraden994Explorer
Thank you a lot for this explanation! I'll treasure it and try something similar. Finger crossed 🤞
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 3 years ago
- 7 months ago
- 4 years ago