This time, we will introduce how to grab an object in STYLY for Vision Pro and trigger actions when grabbed.
Implementation Method
We will grab a Cube this time. The Cube’s name will be “SelectCube.”
Attach the XR Grab Interactable component to “SelectCube” from Add Component.
Also, attach a Script Machine to “SelectCube.”
*Note: Objects cannot be used without a collider. Please attach one if it’s not present.
Open the Interactable Events of XR Grab Interactable.
Press the + in the Select section and drag and drop SelectCube into the box.
Select Entered sends a signal to start processing when the object is grabbed.
Select Exit sends a signal to start processing when the object is released.
Press the No Function box and choose TriggerUnityEvent from the ScriptMachine section.
Give a name in the red frame section. This time, we named them StartSelect and ExitSelect.
Create a Script Graph. We named it “GrabTest.”
Press Edit Graph to open the Script Graph.
This time, we will change the color when the object is grabbed.
Add the following nodes:
- UnityEvent
- Renderer Get Material
- Set Color
Enter the name you set in the Select section into the Unity Event.
Run the process.
Explanation of Sample Scenes with Grabbable Objects in STYLY
Grabable with Gravity and Grabable without Gravity
The difference between Grabable with Gravity and Grabable without Gravity is whether the RigidBody’s Use Gravity checkbox is checked or not.
Grabable with Gravity
Grabable without Gravity
Grabable and Scalable
Grabable and Scalable works by attaching the XR General Grab Transformer in addition to XR Grab Interactable.
Grabable and Scalable
Reactive Grabable can be implemented using the method introduced this time.
This time, we introduced how to create the grabbing functionality in STYLY For Vision Pro.