Just as in traditional gaming, movement is crucial in VR to interact with the virtual environment. In VR, we must provide users the ability to move their in-game character seamlessly. Users typically expect standard movements like moving right, left, forward, and backward.

VR experiences are primarily first-person, putting the user in the role of the protagonist. Our game will incorporate the following movement capabilities:

  • Continuous movement: Users can move freely in any direction: right, left, forward, or backward.

  • 360 degrees of freedom: Users can explore the VR world from any angle, with the ability to rotate their heads. The Unity XRI Toolkit simplifies this with the snap and continuous turn functionality.

  • Teleportation: Users can instantly transport themselves to any location within the virtual world by pointing their controllers.

Implementation and configuration

Now, let’s delve into the types of locomotion available in VR and how to configure them for our game.

Action-based vs. device-based

There are two primary systems for configuring VR locomotion in our game:

  • Action-based: This system enables us to gather user inputs indirectly using the Input System, eliminating the need to code for each specific device. When developing a cross-platform game, an action-based approach is highly recommended.

  • Device-based: This system takes a more direct approach by utilizing methods like InputDevice.TryGetValue to respond to player input. For instance, if we’re creating a game exclusively for Oculus Quest 2, the device-based approach is suitable.

Organization of Locomotion System

The XR Origin represents the player/user in the game, and moving the XR Origin results in player movement. The XRI Toolkit provides various providers (components) and a Locomotion System to facilitate this. These providers offer different movement functionalities to the XR Origin, such as movement across the scene. The Locomotion System acts as a bridge, ensuring that multiple providers do not interfere with the XR Origin simultaneously. Let’s explore each component of the Locomotion System.

Get hands-on with 1400+ tech skills courses.