Search Unity

Question MRTK Handtracking seems lost on pause even though hands render

Discussion in 'VR' started by Gatinha123, Mar 11, 2022.

  1. Gatinha123

    Gatinha123

    Joined:
    Apr 30, 2018
    Posts:
    13
    I'm using the MRTK toolkit with the oculus XR plugin to have some extra assets.
    I have a small pop up menu that's supposed to show when the player faces their palm to the camera for a certain amount of time, and disappear when facing away from the camera.
    This works, however, if the application is paused and resumed for whatever reason by system means (on the device I'm using, the Oculus Quest 2, this is done by pressing the index and thumb fingers while facing the camera) the angle calculations stop working, they are stuck very close to the same number (the one that it last calculated before pausing), regardless of my hand orientation.
    My hands however, miraculously render just fine, and rotate and follow my hand just fine.
    What could be wrong? Here's the code I'm using.

    Declaration + Start:
    Code (CSharp):
    1. IMixedRealityHand handRight;
    2. float angle = 180;
    Update function:
    Code (CSharp):
    1. //handtracking angle calculation
    2.         if (handRight == null)
    3.         {
    4.             handRight = HandJointUtils.FindHand(Microsoft.MixedReality.Toolkit.Utilities.Handedness.Right);
    5.             Debug.Log("Finding hand...");
    6.         }
    7.         else if (handRight.Enabled)
    8.         {
    9.             handRight.TryGetJoint(Microsoft.MixedReality.Toolkit.Utilities.TrackedHandJoint.Palm, out var pose);
    10.             angle = Mathf.Abs(Vector3.Angle(pose.Up, Camera.main.transform.forward));
    11.         }
    12.         else
    13.         {
    14.             angle = 180;
    15.         }
    Additionally, just have a small debugUI where I print the angle to keep track of it.
     
  2. glenneroo

    glenneroo

    Joined:
    Oct 27, 2016
    Posts:
    231
    Stupid question but are you maybe setting timescale to 0 and using Time.deltaTime in your calculations?
     
  3. Gatinha123

    Gatinha123

    Joined:
    Apr 30, 2018
    Posts:
    13
    Sorry for the delay, timescale is set to 1 throughout my game, as for Time.deltaTime, I don't use it at all for the angle calculations, they are calculated each frame on Update().
    In case it is relevant, I am running the game in the editor through OculusLink.
    Note: Tested it, building and running on Oculus has the same problem :(
     
    Last edited: Mar 18, 2022
  4. Gatinha123

    Gatinha123

    Joined:
    Apr 30, 2018
    Posts:
    13
    Update: Still no success, but found out that this "pause" state isn't detected by Unity's OnApplicationPause() or OnApplicationFocus().
    Was attempting to locate the hands again after the "pause" oculus menu as a solution...
    VR is a bit hardware limiting, so didn't want to be finding the hands each frame and consuming pointless precious resources, but might have to resort to that :(