Moving Around in VR

December 31, 2021

Oculus sample framework provides some prefabs to enable player movement in a Unity VR Game.

Lets add one to our VR scene.

The provided Player Controller Prefab uses custom hand meshes as controllers and enables player stick movement, so first remove the static OVRCameraRig added in the first article in this series.

Delete Camera Rig

Next drag the Player Controller prefab from the Assets > Oculus > SampleFramework > Core > Locamotion folder into your scene.

Player Controller Prefab

Player Controller In Scene

When you build and run movement is enabled with the left thumbstick, while rotation is enabled with the right stick and via HMD rotation.

However, pushing the left stick all the way forward will show a red laser pointer and player movement will stop. This is part of the teleportation functionality provided by the prefab, which we are not using for this demo, so lets disable it.

Go to the LocomotionController child of the Player Controller and uncheck the teleportation components.

Locomotion Controller

That should leave only stick based movement in the scene.

Build and run and you can now walk around your beautiful terrain.

VR Movement

To prevent the player falling off the edge of the world, simply create some box colliders at the edges of the terrain that the player can't pass through.


Sharing is caring

Stay In Touch

Connect with Me

© 2021, Created by me using Gatsby