Project 2: Barrel Bouncer VR Edition

Part 3: Movement in VR

In class, we discussed the challenges of implementing movement in VR, specifically in regards to the user’s experience. Smooth and gradual changes in acceleration and rotation, such as that from your project 1 player controller implementation, are a great way to control movement in games and simulations designed for 2D screens. However, such forced movement can cause motion sickness when a user is in an immersive VR experience, since there is a mismatch between what their eyes perceive and the signals that their brain is receiving from the rest of their body. As a result, various other methods of controlling movement were devised. Two in particular (snap rotation and teleportation) are particularly great for beginner VR experiences, as they enable quick, nearly instantenous movements that place you into a new position without giving your brain enough time to realize that something doesn’t feel right.

Example Scene

The Oculus Sample Framework we described in part 1 provides a sample scene called “Locomotion” with an example implementation of the teleportation and snap rotation functionalities. The scene can be found in the following folder: Assets -> Oculus -> SampleFramework -> Usage. It may be useful for you to reference as you work on this section. The documentation that explains how the scene works can be found here.

Basic Setup

The components that enable snap rotation and teleportation make use of a Capsule Collider and a Rigidbody attached to the player, and thus they will not work without these components. Go ahead and add them to your OVRCameraRig, since that is representing your player.

There are a few properties we will want to change for each of these:

Snap Rotations

In this subsection, you will add in the snap rotation functionality, depicted below:

GIF showing snap rotation in action

Start off by adding the Simple Capsule With Stick Movement script from the Oculus Integration onto your OVRCameraRig. This script defines some basic player controller functionality that allows the user to:

Since we’ve already discussed why the first functionality can be unnatural and sickening, we will disable this functionality and only make use of the script’s second functionality. Go ahead and change the following properties of the Simple Capsule With Stick Movement as described below:

Teleportation

In this subsection, you will add in the teleportation functionality, depicted below:

GIF showing teleportation in action

Obtaining the Locomotion Controller

The Oculus Integration defines numerous scripts related to teleportation that all work together. Rather than having you add each of them individually onto a new GameObject, you will copy the LocomotionController GameObject from the example scene (described above) into your scene, as it already has all the scripts neccessary to implement teleportation via the Oculus integration.

  1. Open up the “Locomotion” scene from the Oculus Sample Framework.
  2. Find the LocomotionController GameObject in the scene (it’s a child GameObject of the PlayerController) and make a prefab out of it by dragging it into the Project Window.
  3. Switch back to the main gameplay scene of your barrel bouncer project.
  4. Add an instance of the LocomotionController prefab into the root of your scene positioned at origin.

Setting Its Properties

Next, you will have to set multiple properties on various components of the Locomotion Controller GameObject, as listed below

Defining an Where to Teleport

At this point you have set up all the functionality necessary for your player to teleport, but you haven’t defined anywhere where you can teleport onto. The Oculus Integration provides three different ways to define where you can teleport:

For this project, we will be using the last method. The Teleport Target Handler Physical script on the Locomotion Controller defines a property called Aim Collision Layer Mask which allows you to select all possible layers that you would like to enable teleportation onto. By default, this is set to the Ground Layer that the Oculus Integration defined. Go ahead and set any GameObjects representing your floor or ground to this layer.

Additionally, you may choose to be creative with where you are allowed to teleport onto. For example, you may decide that you want to be able to teleport on top of a roof or onto tree branches. Since these are not technically part of the ground, they should not be included on the Ground layer, but you can easily create a new Layer called “Teleportable” and set all other GameObjects you want to be able to teleport onto that layer. Just make sure to add that layer onto the Aim Collision Layer Mask.

Bonus Task (Optional)

Previous Section | Go Home | Next Section