Search code examples
unity-game-engineaugmented-realityhololensmrtk

MRTK 2.4 - Reattach Hand Menu


I used the prefab HandMenu_Large_WorldLock_On_GrabAndPull as a basis for my hand menu. If grabbing the menu and placing it somewhere, I stays there and this behavior is fine for me. But now I want to walk away, looking again at my hand and the menu should reattach to my hand. How to set up HandConstraintPalmUp to achieve that?

What I tried:
I read here that I could set the SolverHandler to true or call the method HandConstraintPalmUp.StartWorldLockReattachCheckCoroutine() but this is actually not setting the SolverHandler to true, it just stays false. If running it via Holographic Emulation and setting the handler to true by clicking in the editor, it works, but not via OnFirstHandDetected or OnHandActivate of HandConstraintPamlUp. Also the documentation says:

When trying to set the hand constrained object to start following your hand again (based on whether it meets the activation criteria), set the SolverHandler's UpdateSolver to true.

But what is the criteria for the solver to set UpdateSolvers to true? What am I missing here?

Menu with default settings:
Why is for example the OnClick-Event on the button BtnClose working and my call on OnHandActiavte not? enter image description here


Solution

  • Actually, since the Use Gaze Activation checkbox of HandConstraintPalmUp component is disabled by default, and the coroutine function WorldLockedReattachCheck() invoked by StartWorldLockReattachCheckCoroutine() method has a conditional statement will evaluate the useGazeActivation property to decide whether to execute the statements following. If you did not enable the Use Gaze Activation, it will never update the UpdateSolver property to true. You can refer to the source code of this class for details: HandConstraintPalmUp.cs Line 392. To fix it, you can enable the Use Gaze Activation for your project or update the value of SolverHandler.UpdateSolvers directly in your code.

    Besides, the OnHandActiavte event is always work fine for me, I can't reproduce your issue on my machine. Could you provide more information about it? And if you have question about how to use it, you can find examples in the HandMenuLayoutExamples scene under Assets/MRTK/Examples/Experimental/HandMenuLayout/Scenes.