text
stringlengths 0
1.11k
|
|---|
Your scene is now ready to build.
|
Select File > Build And Run, or if you have an Oculus Link connected, click Play.
|
Grabbing any item in the scene with your left hand activates the active state, causing the cube to glow green.
|
Left hand grabbing object, activating active state
|
Check state of multiple elements
|
In this scenario, you’ll add to the previous scenario by checking the active state of both hands, not just the left hand. To check the state of a group of elements, you use an Active State Group component. In an Active State Group, each element is evaluated, and then the group is evaluated using its boolean operator to return a final value of either true or false.
|
Open the modified HandGrabExamples scene from the previous scenario.
|
Under Hierarchy, select Cube.
|
Under Inspector, add a second Interactor Active State component.
|
In that component, set the Interactor property to the HandGrabInteractor for the right hand, which is located under OVRCameraRig > OVRInteraction > OVRHands > RightHand > HandInteractorsRight > HandGrabInteractor.
|
Set the Property property to Is Selecting to detect when the hand is grabbing.
|
Interactor and Property properties
|
Add an Active State Group component, which checks the value of its active states and returns a final boolean value.
|
In the Active State Group component, add two empty elements to the Active States list.
|
Set the elements to the two Interactor Active State components, which are listed in the Inspector above the Active State Group component.
|
Set the Logic Operator field to OR so that either hand can activate the Active State.
|
Active State Group component
|
In the Active State Debug Visual component, set the Active State field to the Active State Group component. This causes the cube to monitor and display the final state of the Active State Group.
|
Active State property
|
Select File > Build And Run, or if you have an Oculus Link connected, click Play.
|
Grabbing any item in the scene with either hand or both hands activates the active state, causing the cube to glow green.
|
Both hands toggling Active State
|
Related topics
|
To learn about the concept of active state, see Active State Overview.
|
To understand how poses are detected, see Hand Pose Detection.
|
To learn how to make a custom hand pose, see Build a Custom Hand Pose.Use the Data Property
|
Unity
|
All-In-One VR
|
Quest
|
The platform for which this article is written (Unity) does not match your preferred platform (Nativa).
|
Haz clic aquí para ver la página del índice de la documentación para tu plataforma de preferencia.
|
In Interaction SDK, interactors and interactables both have an optional Data property that takes an object you can read from and write to. That object lets you share additional information with an interactor or interactable, like which hand grabbed an object. In this tutorial, you learn how to use Data to store and read data so a controller will vibrate when it grabs an object.
|
Example use case
|
Here’s one example of how you could use Data. Suppose you’re making a ping-pong paddle that should vibrate using haptics when it collides with the ball. The haptic code will live in the interactable (not the interactor), so it can have different parameters depending on the paddle material and collision strength. However, there’s one problem, you don’t know which controller should vibrate! To solve that, you can pass an object with information about the active controller to the interactor’s Data field, and then read that on the interactable side to know which controller should vibrate.
|
Write data to GameObject
|
In order to use Data, you need a GameObject to store information. To avoid having to set up controllers, you’ll add to the existing HandGrabExamples scene. The additions you make to the scene can be easily reverted once you complete the tutorial.
|
In Unity, open the HandGrabExamples scene.
|
Under Hierarchy, select the HandGrabInteractor located at OVRInteraction > OVRControllerDrivenHands > LeftControllerHand > ControllerHandInteractors > HandGrabInteractor.
|
View in Hierarchy
|
Under Inspector, in the Hand Grab Interactor component, set Data to the Hand Ref component. You do this because Hand Ref contains a public variable defining which hand is active, so linking that component to the Data field lets you access that information later.
|
Setting Data property
|
Repeat these steps for the HandGrabInteractor under RightControllerHand.
|
Read data from GameObject
|
Now that Data contains Hand Ref, the grabbable object can read Data to find out which controller is active and cause that controller to vibrate.
|
Under Hierarchy, create a copy of the SimpleGrab0NoPose GameObject (the blue cube).
|
Rename it to CopyCube so you don’t confuse the new cube with the original.
|
Using the Transform gizmos, reposition CopyCube so it’s separate from the original cube.
|
Under Project, open the Scripts folder.
|
Scripts folder
|
In the Scripts folder, create a new script called ReadData by right-clicking and selecting Create > C# Script.
|
Creating a new script
|
Open the ReadData script in your code editor.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.