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”
The first thing we will do is make an empty child object of “CubeBottle” and we will set the transform so the location matches that of the child object. (Maybe name it “placeholder AttachPoint” so it is easy to keep track)
Next, we will right-click on the Cube in the Hierarchy window, then select Motive > Make Grabbable
After this, make sure Is Trigger in the Box Collider component is checked True
After that, right-click on the Cube again and select Motive > Make Attach Receiver
Next, right-click on the Sphere, then select Motive > Make Attachable
Once all the necessary components have been added. Now 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
After that set the Type to something easy to remember. In this case we will just put “Test”
Then set Max Attachments to 1
Next, expand the VR Attachable component on the Sphere
Expand the Attaches To dropdown and type 1 into the size
After that set the Type to the same string used before. In this case, “Test”
Then, drag and drop your previously made “AttachPoint” into the Receiver Attach Point box