Making an Interactive Prop

From VR Wiki

ChilloutVR Props are able to trigger animations, much like the advanced avatar menu can. Triggers can be activated by the interaction button on your VR controllers or the appropriate key in desktop, by opening a menu page, by collider interactions, or by a wide number of other interactions.

This tutorial will give you some knowledge on how to make a simple prop interactive.



Prerequisites

  • Knowledge of how to work with components
  • Knowledge of how to work with GameObjects in the Scene Hierarchy

Making an Example Prop

To show you how the system works in a very simple, easy-to-understand way, we will be making a simple prop that changes from a cube to a sphere when the interaction trigger is pressed. It will do this by enabling a sphere and hiding a cube.

  1. Create an empty GameObject in your scene.
  2. Create a cube inside of the GameObject.
  3. Create a sphere inside of the GameObject.
  4. Disable the sphere.
  5. Make the GameObject a prop.

Making an Interactable

  1. Select the prop's root GameObject
  2. Add a CVR Interactable component to the GameObject.
  3. Change the Tooltip property to read "CHANGE ME".

Now we do the fun part.

Add a Trigger

A trigger is what activates a set of actions within the Interactable. A trigger can be activated by one of many events, most commonly by usage of the Interact input (trigger on VR sticks, mouse-left on desktop). For our purposes, we will use On Interact Down, which is activated when the interact key or grip is pushed down by the user. When the key or grip is raised, we will also capture On Interact Up to undo the changes we made in On Interact Down.

  1. Inside the CVR Interactable component, click Add Trigger
  2. For the Trigger property, select On Interact Down.
  3. Leave everything else alone.

Add an Action

An action is a task the game will perform when a trigger's conditions are met. A number of actions are available, but we will be making use of a simple Set Game Object Active action.

  1. Click Add Action.
  2. In the new Action, select Action Type to Set Game Object Active.
  3. Drag the cube inside the GameObject to Target.
  4. Set State to Disable.
  5. Create another action that enables the sphere.

Wrapping Up

Now to finish the prop.

  1. Create another trigger that is activated by On Interact Up.
  2. Inside this trigger, add an action that enables the cube.
  3. Add an action that disables the sphere.

And you're done! Upload to test.