Making an Attachable Prop
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
- Make a simple cube primitive in the scene. This will be our hat.
- Make the cube a prop.
- Add a CVR Attachment component to the cube.
- Set the Attachment Type to Bone.
- Set Bone Type to Head.
- 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:
- Create a trigger for On Grab.
- Make the Broadcast Type Local Not Networked.
- Add a Method Call action to On Grab.
- Select Runtime Only in the first dropdown.
- Select CVRAttachment.DeAttach in the second dropdown.
- Drag and drop the GameObject containing the CVR Attachable component into the third box.
Now to tell it to try to attach when dropped:
- Create a trigger for On Drop
- Make the Broadcast Type: Local Not Networked.
- Add a Method Call action.
- Select Runtime Only in the first dropdown.
- Select CVRAttachment.Attach in the second dropdown.
- Drag and drop the GameObject containing the CVR Attachable component into the third box.
You're done!