Nested Grabbables and Attachables
In depth learning on Attachable Basics is found in this course in Motive Academy.
- 1 Overview
- 1.1 Setup
- 2 Related Articles
Overview
This article describes how to make a cube (our bottle) with a sphere (our cap) attached to it as a child. And, make it so both the cube and the sphere can be grabbed and moved around separately, then reattached.
We will do this using three premade Motive SDK features:
VR Attachable
VR Attachable Receiver
VR Grabbable
Setup
For this example, we are starting with this relatively simple two-part “Bottle and Cap”:
Make an empty child object of “CubeBottle”
Set the transform so the location matches that of the child object.
Give it a name such as “placeholder AttachPoint” so it is easy to keep track of
Right-click on the Cube in the Hierarchy window
Select Motive > Make Grabbable
Ensure Is Trigger in the Box Collider component is checked False
Add a second smaller collider that is placed where the “cap” is meant to attach
Set Is Trigger to True. (This makes it so the cap and the bottle both behave so that they cannot fall through the floor. But, can reattach)
Right-click on the Cube again
Select Motive > Make Attach Receiver
Right-click on the Sphere
Select Motive > Make Attachable
Now all the necessary components have been added. Next we will make it so the Attachable and the Attachable Receiver can talk to each other.
Expand the VR Attachable Receiver component on the Cube
Expand the Receivers dropdown and type 1 into the size
Set the Type to something easy to remember. In this case we will just put Test
Set Max Attachments to 1
Expand the VR Attachable component on the Sphere
Expand the Attaches To dropdown and type 1 into the size
Set the Type to the same string used before. In this case, “Test”
Drag and drop your previously made “AttachPoint” into the Receiver Attach Point box:
Related Articles