introduction
In oculus quest2, the poke button on the fingertips of the hand does not pass through the membrane. Specifically, the code is used to limit it. For details, see HandPokeLimiterVisual.cs in the oculus quest package. The following implements other objects (small balls) as pokeInteractors to poke the button. The ball does not see through the button when pressed.
First of all, let’s talk about the logical way to realize the official fingertips.
Official fingertip poke limit
poke master - fingertips
The specific gesture tracking uses the module structure in the case of Interaction->Scenes->Examples->PokeExample in the oculus package. Among them, we see that HandPokeInteractor mounts important Poke Interactor and Hand Poke Limiter Visual codes.
In the list presented by the red box of Poke Interactor, we can see a variable Point Transform, which imports the coordinates of the fingertip, and here imports the coordinates of the index finger. Therefore, if you want to become the leader of poke, you need to mount this code, import the coordinates of the leader of poke, and then you can see the case of the small ball more clearly.
If you don’t want to wear the mold, the leader should also mount the limit code. For the hand code, it is mainly: when it is detected to be pressed, change the position of the fingertip so that it is limited within a certain range, and then lock it. Control the pose of the wrist to avoid immobilization of the fingertips and random turning of the wrist, but other fingers without limit can still move after the actual measurement.
touchPoint is the pressed surface, delta is the displacement of the previous frame, radius is the radius that limits the movement, touchnormal is the normal of the poke, that is, it will only move the radius distance along the normal.
The radius can be changed from the parameters of the Poke Interactor above.
poke-key
The poke user mounts poke interactable, mainly these are parameters such as the hover of the button, the select press and so on.
And mount the Interactable unity event to set various events that occur when the button is pressed.
broadcast
After setting the poker and pokee, set pointableCanvasModule to mount eventSystem and PointableCanvasModule for broadcasting.
Small ball case
poke leader - small ball
Create a small ball, mount the two codes mentioned above on the small ball, and drag the small ball into Point Transform. See the github code
for Ball Limit , give it a star~
Subject-Key
Put the two codes mentioned above on the key.
In order to allow the ball to press the button vertically for a longer distance is still limited, the cancel select normal here is changed to 1, the previous ten 0.3 is too short, that is, when the ball is more than 1 downward on the surface of the button, it is considered to be unselect, and our limit code will be limited when select = true.
Buttons can also set event responses according to different states. In this component, we can add events to the list, and then mount our response function here.
For example, the following example:
Buttomvisual is one of my components, there is an interactableColorVisual code on the component, and there are public functions synHover() and synSelect() in the code.
Drag and drop the component in this list, and then select the code and the corresponding function to be responded to on the right.
broadcast
Similarly, we need to set the broadcast, just like the official module, please see the settings in the screenshot above.