Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
Haraden994's avatar
Haraden994
Explorer
4 years ago
Solved

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.

  • Anonymous's avatar
    Anonymous
    4 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's avatar
    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.

     

     

    • Haraden994's avatar
      Haraden994
      Explorer

      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's avatar
    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.

    • Haraden994's avatar
      Haraden994
      Explorer

      Thank you a lot for this explanation! I'll treasure it and try something similar. Finger crossed 🤞