Nested Grabbables and Attachables

In depth learning on Attachable Basics is found in this course in Motive Academy.

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”:

 

  1. Make an empty child object of “CubeBottle”

  2. Set the transform so the location matches that of the child object.

  3. Give it a name such as “placeholder AttachPoint” so it is easy to keep track of

  4. Right-click on the Cube in the Hierarchy window

  5. Select Motive > Make Grabbable

  6. Ensure Is Trigger in the Box Collider component is checked False

  7. Add a second smaller collider that is placed where the “cap” is meant to attach

  8. 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)

  9. Right-click on the Cube again

  10. Select Motive > Make Attach Receiver

  11. Right-click on the Sphere

  12. 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.

  1. Expand the VR Attachable Receiver component on the Cube

  2. Expand the Receivers dropdown and type 1 into the size

  3. Set the Type to something easy to remember. In this case we will just put Test

  4. Set Max Attachments to 1

  5. Expand the VR Attachable component on the Sphere

  6. Expand the Attaches To dropdown and type 1 into the size

  7. Set the Type to the same string used before. In this case, “Test”

  8. Drag and drop your previously made “AttachPoint” into the Receiver Attach Point box:

Related Articles

Recipes