Made With Unity | Unity VR Part 3: Move In VR

Rehtse Studio
5 min readJun 1, 2022

There are two basic ways to use VR Locomotion in Unity: Teleportation and Continuous Movement(moving with the joystick).

To use this locomotion features in Unity, we need to add in our Hierarchy the Locomotion System script component and the Teleportation Provider script component.

Create a new 3D object and called it Locomotion Manager; add the components Locomotion System and the Teleportation Provider, make the necessary reference as the image shows.

TELEPORTATION

OpenXR provided us with two teleportation components: Teleportation Anchor and Teleportation Area.

TELEPORTATION ANCHOR

The Teleportation Anchor script component allows you to place a anchor / specific spot where you want to player to be in a particular section of the level.

A new Interaction Layer Mask called Teleportation was created and will the added to the teleportation spot, the same layer must be applied to the the Hands Controller that are using the XR Ray Interactor.

In the following image each square teleportation spot game object has a Teleportation Anchor script component and a child game object called Anchor. The Anchor game object goes in the Teleport Anchor Transform field on the Teleportation Anchor script component. Depending on where the Anchor is place is where my player will be anchor to.

The Default Anchor dose not have a the Anchor child game object, by default if there's no object to be the Anchor, the script will use the default position of the game object that has the Teleportation Anchor script component.

The Left Anchor spot has is Anchor to the left side, regardless on where is the teleportation spot the Anchor will move the player to the left side.

The Center Anchor has the Anchor game object in the center of the teleportation spot

The Right Anchor spot has is Anchor to the right side, regardless on where is the teleportation spot the Anchor will move the player to the right side.

TELEPORTATION AREA

The Teleportation Area script component allows you to move in any section of the level depending on where you aim your ray. We add the Teleportation Area script component with the Interaction Layer Mask of Teleportation, to any object pretending is our floor.

CONTINUOUS MOVEMENT

TURNS

Turn script components allowed us to turn our player with the help of the Joystick in our controllers; we have Continuous Turn Provider and Snap Turn Provider.

Continuous Turn Provider (Action-based)

On your XR Origin / Player add the component Continuous Turn Provider (Action-based) in order to turn / rotate smoothly on the environment without rotation in the real world.

Snap turn Provider (Action-based)

Adding the Snap Turn Provider (Action-based) component will allowed to turned with a snapping effect.

MOVE

For a complete move system we have Continuous Move Provider (Action-based), it will allowed us to use the Joystick to move Forward, Back, Left and Right. On the Forward Source field we add our XR Origin object to get his forward.

If we want to control the rotation base in how we rotate our body in the real world, we add the Main Camera from our XR Origin in the Forward Source field. Remember that our Main Camera is being controlled with our VR Headset, where we rotate is where our forward will be.

COMBINING COMPONENTES

My XR Origin has a Continuous Move Provider (Action-based) and have a Snap Turn Provider (Action-based); with this combination I can move with my Left Joystick Hand Controller, rotated in the real world controlling my rotation in my VR environment and if I am sitting and can’t move I can Snap Turn using my Right Joystick Hand Controller.

🎮PART 4🎮

--

--

Rehtse Studio

Game Developer sharing content around Unity, programing and tips and tricks in game dev.