Kick off the Escape Room Project

Simon Pham
4 min readDec 1, 2023

--

Project Description

This is an escape room VR project where you are trapped in a boiler room and have to find a way to escape.

Installing the XR Interaction Toolkit

The first thing that I want to do is to give the player a body, hands and tools to interact with objects the room.

Let’s install the XR Interaction Toolkit from Package Manager, and import the Start Assets and XR Device Simulator (for testing purposes).

Creating an XR Origin

In the VR world, XR Origin is the player’s perspective in a scene so we would want to configure it properly at the early stage. To create one, right-click in the Hierarchy and select XR > XR Origin (VR).

There are a few components in the XR Origin object including main camera, lefthand and righthand controller.

Main Camera

The Main Camera object will act as the player’s head and includes two important components which is a Camera that represent eyes and a Tracked Pose Driver that takes in player’s input and applies it to the Main Camera object’s transform.

Camera Component

For the Tracked Post Driver component, I’m gonna match the input references with the correct XRI default input actions.

Tracked Pose Driver Component

Lefthand and Righthand controller

These objects each has an XR Controller, akin to the Tracked Pose Driver. The XR Controller also receives input from the player’s controller and applies it to the character’s actions.

A quick way to set up these controllers is to use Unity presets.

Configuring XR Origin

We’ve created an XR Origin, now let’s configure it so that we can move around.

Locomotion System

Locomotion is a component that acts as the middle man between the XR Origin and move providers. To set this up, I can simply select the XR Origin object, add the Locomotion System and drop the XR Origin component into its corresponding field.

Moving and Turning

One of the easiest way to move around in the VR world (at least for me) is to use the righthand controller to turn, and the lefthand one to move back and forth.

To set this up, I’m gonna add the Snap Turn Provider and Continuous Move Provider components to the XR Origin object, use the Unity presets, drop the Locomotion System component into its corresponding field for both, and uncheck the hand controller that we’re not using for each component.

Continuous Movement is bound to the lefthand controller
Snap Turn is bound to the righthand controller

Next, I’m gonna add a Character Controller and a Character Controller Driver to give the body a collider and dynamic height meaning that it will adjust when the player stands or sits.

With all of that configuration, we now should be able to move, turn and collide with objects in the room. And here’s the result:

In the next article, I’m gonna talk about teleportation and giving the player hands.

--

--

No responses yet