Adding Interactivity to Virtual Objects

Follow step-by-step instructions to learn how to interact with GameObjects in a virtual environment.

Realistic interactivity

The core component of an immersive experience is the freedom to interact within the scene. The more realistic the interactions, i.e., similar to our real-world interactions, the more immersive the virtual experience gets. In the real world, we can interact with objects; for example, if we see a ball lying on the ground, we can pick it up and throw it. Similarly, if we want to make the virtual experience more realistic, then our virtual environment must offer the user to interact with the ball seamlessly.

In this lesson, we’ll place various cricket balls in our scene and learn how to add interactivity to the scene so that we can grab the balls.

Adding a grab interaction

The XR Toolkit contains a component that allows basic grab functionality. When attached to an object, the object follows the principles of physics. To make any object interactable, we have to add the “XR Grab Interactable” component to it.

  1. In order to add grabbing functionality to an object, click it in the “Hierarchy” panel and navigate to its “Inspector” panel.

  2. Click the “Add Component” button and search for “XR Grab Interactable.” Add this component.

  3. Now, make sure that in the “Interaction Manager” option, “XR Interaction Manager” is selected. Otherwise, add “XR Interaction Manager” by clicking on the field.

  4. After adding the component, we also add basic physics properties to it. When we add the XR grab component to an object, it will automatically attach a rigid body to it as well. We can modify these properties listed in the component.

Get hands-on with 1200+ tech skills courses.