Making an Attachable Prop

From VR Wiki

ChilloutVR props are useful, but sometimes you want to attach them to your avatar for some reason. A simple example that this tutorial will use is a hat that one wants attached to your avatar's head.



Prerequisites

  • Knowledge on how to manipulate GameObjects in the Scene Hierarchy
  • Knowledge on how to manipulate Components in a GameObject
  • Knowledge on how to make a basic prop.
  • Knowledge on how to make Interactable Props.

Creating a Simple Attachable Prop

  1. Make a simple cube primitive in the scene. This will be our hat.
  2. Make the cube a prop.
  3. Add a CVR Attachment component to the cube.
  4. Set the Attachment Type to Bone.
  5. Set Bone Type to Head.
  6. Set Max Attachment Distance to something like 0.5. If you drop the attachable within this radius, it'll attach to the bone/tracker.

Making it Actually Work

The Attachable needs to know when to activate and deactivate. So, we'll use a simple Interaction.

First, tell it to disconnect when grabbed:

  1. Create a trigger for On Grab.
  2. Make the Broadcast Type Local Not Networked.
  3. Add a Method Call action to On Grab.
  4. Select Runtime Only in the first dropdown.
  5. Select CVRAttachment.DeAttach in the second dropdown.
  6. Drag and drop the GameObject containing the CVR Attachable component into the third box.

Now to tell it to try to attach when dropped:

  1. Create a trigger for On Drop
  2. Make the Broadcast Type: Local Not Networked.
  3. Add a Method Call action.
  4. Select Runtime Only in the first dropdown.
  5. Select CVRAttachment.Attach in the second dropdown.
  6. Drag and drop the GameObject containing the CVR Attachable component into the third box.

You're done!