The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
how do i create my own class for gesture hold and tap from scratch?
how do i create my own class for gesture hold and tap from scratch?
i wanna have a simple function of hold and tap
like if i hold and leave how to know when i leave the gameobject
Best Answers
-
mtoronto ✭
First part is you want to create a new script which inherits from Singleton<> and an empty Game Object in your scene on which you put this script as a component.
You can create a rough estimate of where your hand is pointing by using the gaze direction of the camera and the position of a detected hand. Right now there is no way to figure out what the hand is pointing at so this does not always work perfectly.
You can listen to the following InteractionManager events in your script to detect hands and their movement. Set the event handlers in the Awake method. Don't forget to unbind the handlers in the OnDestroy function of the script.
InteractionManager.SourceDetected
InteractionManager.SourceLost
InteractionManager.SourceUpdatedTo detect if a hand is on top of a game object then that game object must have a Collider. You can figure out if a hand is above a game object in the SourceDetected and SourceUpdated event handlers as so where hand below is the InteractionSourceState parameter of the event handler.
// Get the raycast hit information from Unity's physics system. RaycastHit hitInfo; //use the hand position but we have no direction for hand so use the gaze direction. var hit = Physics.Raycast(hand.transform.position, Camera.main.transform.forward, out hitInfo, 25.0f, Physics.DefaultRaycastLayers); //if we hit something with a collider. var focusedGameObject = Hit && hitInfo.collider != null ? hitInfo.collider.gameObject : null;
5
Answers
First part is you want to create a new script which inherits from Singleton<> and an empty Game Object in your scene on which you put this script as a component.
You can create a rough estimate of where your hand is pointing by using the gaze direction of the camera and the position of a detected hand. Right now there is no way to figure out what the hand is pointing at so this does not always work perfectly.
You can listen to the following InteractionManager events in your script to detect hands and their movement. Set the event handlers in the Awake method. Don't forget to unbind the handlers in the OnDestroy function of the script.
InteractionManager.SourceDetected
InteractionManager.SourceLost
InteractionManager.SourceUpdated
To detect if a hand is on top of a game object then that game object must have a Collider. You can figure out if a hand is above a game object in the SourceDetected and SourceUpdated event handlers as so where hand below is the InteractionSourceState parameter of the event handler.
Thanks so mush
If the response answers your question please go ahead and mark it as answered. Thanks!