Search code examples
unity-game-enginehololensmrtk

How can I change hand-rays in my MRTK v2 project for HoloLens 2 to parabolic instead of linear?


My HoloLens 2 project has content that is arranged as such I cannot target colliders with the existing hand-rays. I used to target my content with the head-gaze, but with hand-rays being lower on the body it is more difficult to reach the content that I want to select. I believe I would benefit from a parabolic selection ray, similar to those used when teleporting in Mixed Reality to reach surfaces above the participant.

The primary method of interacting with my content would be via a parabolic ray. There are instances within my application where I might change modality to focus on a menu system from close or far, and when I am far I'd like to change to a linear ray. So, having this capability to change the type of ray exposed via code would be preferred.

My project is employing the MRTK v2, and the standard linear hand-rays are functioning.

I would like to be able to change the type of ray being used in the Unity inspector, and to be able to change the style via code during run-time. I'd like to have control over the arc of the ray, as the scale of my content may impact the need for a different arc and min/max distance.


Solution

  • You can modify the DefaultControllerPointer prefab to use a Physical Parabolic Line Data Provider instead of a Bezier Line Data provider. This will distort the line used by the pointer to be more parabolic.

    Before:

    enter image description here

    After:

    enter image description here

    Note that I removed the pink components and added the green components.

    You will also want to increase the line cast resolution of the pointer from 2 to something larger, this means that the ray used to query what you have hit will have higher resolution:

    enter image description here

    And you may want to increase the resolution of the MR Line Renderer itself.

    Demo of parabolic hand pointer:

    enter image description here