Locomotion and Ergonomics
View Lesson here
It’s recommended to support all types of movement. Comfort is important.
Physical Movement
Movement in VR that matches physical movement and provides the most comfortable experience because there is no mismatch of senses that could trigger discomfort.
Limitations:
- Play areas
- Small spaces
- How small is too small for the design?
- They simply don’t have the mobility, i.e. they are in a wheelchair
Scripted Movement and Avatar Movement
Scripted Movement
When the perspective moves along a predefined path of motion. This creates vection which is the sensation of movement of the body in space produced purely by visual stimulation.
For example, see yourself riding a rollercoaster while on the couch. Use sparingly
Avatar Movement
A combination of thumbstick, button, headset, motion controllers and gameplay state to drive the motion in a way that makes sense. Studies have shown that the more we move our body while in VR, the more comfortable we can stay.
Immersion is the key to any experience. The more accurately we move to how our character is moving, the better the experience is.
Steering Motion and World Pulling
Steering Motion
The player is controlling inertia.
Near-continuous sex degrees of freedom (6DoF) accelleration and velocity is common and often includes moving at a high speed.
In the past many people didn’t think this would be comfortable.
World Pulling
The player is generally stationary until they grab some point in the world and pull or push it. The world is locked to the controller and movies with it exactly.
Climbing mechanics were the first to use this.
Teleports
An instant, or nearly instant, mechanic where you quickly appear somewhere else. This typically works by aiming a beam and pressing a button.
A good example is Projectile Warping, where you warp to wherever you throw or shoot.
Another approach is Projected Avatars. This is when you push the thumbstick and your avatar walks away from you in a 3rd-person perspective. After you are done moving the avatar, the camera shifts to the avatar’s new location.
Implementing Teleports
- Go to Packages/VRTK Prefabs/Pointers and drag the ObjectPointer.Curved into the scene
- Give it a good name, in this case TeleportCurved.L and TeleportCurved.R
- For the Left control curve we set the Follow Source under Pointer Facade (Script) > Pointer Settings to the LeftControllerAlias, then we do the same with the right
- To keep the scene organized we create an Object to hold other Objects. In this case We create InputHandlers and reset to origin
- Within InputHandlers we create ThumbstickTouched.L and ThumbstickTouched.R
- Select both ThumbstickTouched.L and ThumbstickTouched.R
- Ensure they have the script OVR Input Touch Action attached and under Touch select Primary Thumbstick
- Set Controller to R Touch for right, and L Touch for left
- Now we drag the associated thumbsticks onto the Activation Action in the control curves. ThumbstickTouched.L goes to TeleportCurved.L > Pointer Facade > Activation Action and we repeat for the right
- Test in VR and we should see some targeting beams coming from the controllers when we touch the thumbsticks
OVRInputTouchAction.cs
Add The Teleportation Action
- Drag Teleporter.Instant from VRTK/Prefabs/Locomotion/Teleporters into the scene
- The target of the teleporter is what’s actually moved. Drag PlayAreaAlias into Teleporter.Instant > Teleporter Facade > Teleporter Settings > Target
- The offset field needs to be assigned to the headset alias. Drag HeadsetAlias to Teleporter.Instant > Teleporter Facade > Teleporter Settings > Offset
- Next drag SceneCameras to Teleporter.Instant > Teleporter Facade > Teleporter Settings > Camera Validity
- Under InputHandlers create 2 actions: ThumbstickPressed.L and ThumbstickPressed.R
- Add the button action for both and configure them for each controller. Add the OVR Input Touch Action to both
- While both ThumbstickPressed.L and ThumbstickPressed.R are selected set OVR Input Touch Action > Button to Primary Thumbstick
- Select ThumbstickPressed.L and set OVR Input Touch Action > Button to L Touch and do the same for the right
- Now we tell the curves to select the boolean action when these teleports are triggered. Drag ThumbstickPressed.L to TeleportCurved.L > Pointer Facade > Selection action and do the same for the right
- We need to add a reference to the teleporter object’s teleport function to this list. Drag Teleporter.Instant to the missing object in both TeleportCurved > Pointer Facade > Selected
- Test in VR
Adding a Direction Indicator
- Search “Arrow” in the asset finder and find the arrow model
- Drag and drop in TeleportCurved.L > ObjectPointer.Internal > Elements > Elements.Cylinder
- Reorient arrow as desired
- Search “PointerDefaultValid” to find the material the beam is using
- Drag and drop that as the material for the arrow
- Duplicate the arrow and drag and drop to the same place under the other curve
- Create a high-level game object which we can name “ThumbstickPosition.L” Then copy and paste for R
- Select both and set OVR Input Touch Action > Axis to Primary Thumbstick
- Then assign OVR Input Touch Action > Controller for each hand to their respective L Touch and R Touch values
- Drag ThumbstickPosition.L and ThumbstickPosition.R into the InputHandlers object
- Now we need to set up the action to rotate the arrows. Create a high-level game object which we can name “AccessRotator.L”. Then copy and paste for R
- Next, we need to change the default 2D axis to a 1D axis with our controllers. Within ThumbstickPosition.L create 2 objects named “Thumbstick.X.L” and “Thumbstick.Y.L”. Copy and rename appropriately for R Thumbstick Positions
- Select the 2 Y axis objects of the new Thumbstick axis objects. We need to track all of the axis values we want, so this is how we will take care of that
- Under Vector 2 To Float > Coordinate To Extract select Extract X. Now we need to make sure that when the Vector 2 values are changed the float converters are notified
- To do that we select ThumbstickPosition.L under OVR Input Touch Action > Value Changed add the 2 vectors we just created
- Then change the property No Function to Vector2ToFloat > Vertor2ToFloatDoTransform. Then do the same for ThumbstickPosition.R.Now we need to add a Float action to each of the converters. Search “FloatAction”
- Select all of the Thumbstick Axis Objects and drag the FloatAction script to their properties Inspector
- Add to Vector 2 To Float > Transformed script for each Thumbstick Axis Object it’s own object and change the No Function property to FloatAction > Receive. Next we need to set up the axis rotators to respond to the float actions we just built
- Create a high-level game object which we can name “AxisRotator.L” and copy for R
- In AxisRotator.L > Axis Rotator Facade drag Thumbstick.X.L into Axis Settings > Lateral Axis and Thumbstick.Y.L into Axis Settings > Longitudinal Axis. Then do the same for R
- Drag the TeleportCurved.L > ObjectPointer.Internal > Elements > Elements.Cylinder > Valid Container to AxisRotator.L > Axis Rotator Facade > Target Settings > Target and do the same for the right
- Drag the Tracked Alias > Aliases > Headset Alias to AxisRotator.L > Axis Rotator Facade > Target Settings > Direction Offset and do the same for right
- Set Teleporter.Instant > Teleporter Facade > Offset Usage to Offset Always With Destination Rotation
- Now TEST!
Adding Restrictions to Teleporting
- Add a Layer Called “Teleportable”
- Save that and put Environment > PlayArea > Floor > FloorCollider into this layer by selecting it at the top of the inspector while selected
- Create a new game object and name it TeleportationRule
- Search “AnyLayer” in the Asset finder
- Find the AnyLayerRule
- Drag the AnyLayerRule over to the TeleportationRule
- Set AnyLayerRule > Layer Mask to Teleportable
- Select the 2 TeleportCurved objects and drop the TeleportationRule into Pointer Facade > Target Validity
- Test to make sure you can’t teleport anywhere you shouldn’t
How to Use Teleport Targets
- Create a game object and name it “TeleportTargets”
- Add 2 components. First search for ActionDisplatcher in the asset finder and add it to TeleportTargets
- Do the same with TransformDataProxyEmitter
- In the TransformDataProxyEmitter > Emitted list click the + button and drag Teleporter.Instant into the object input and in the function input select TeleporterFacade > Teleport
- In the asset finder serach “distination” and drag DestinationPoint Variant to the object list under TeleportTargets
- Select all DestinationPoint Variant objects and drag TeleportTargets into Destination Location Facade > Location Events > Activated
- Set the function to TransformDataProxyEmitter > Recieve
- Set the layer to Teleportable and select Yes, change children
- Select the TeleportCurved objects and add a list item to Pointer Facade > Pointer Events > Entered and Exited
- Drag TeleportTargets to the Pointer Facade > Pointer Events > Entered and Exited object
- Set the Pointer Facade > Pointer Events > Entered function to ActionDispatcher.Enter
- Set the Pointer Facade > Pointer Events > Exited function to ActionDispatcher.Exit
- Test and make sure the cursor snaps to the different nodes and that you can teleport to them
Snap Turns, Custom Inputs, Player Occlusion
- Within InputHandlers create 2 objects named “TeleporterActivation.R” and “TeleportSelection.R”
- Search “TeleporterSelection” and add the TeleporterSelection script to TeleportSelection.R
- On both set Teleport Activation/Teleporter Selection > Controller to R Touch
- Under TeleportSelection.R create 2 game objects named “RightTeleport.X” and “RightTeleport.Y”
- Select both and in the asset finder search “FloatAction”
- Drag the FloatAction.cs script to both
- Assign RightTeleport.X/Y to TeleportSelection.R > Teleporter Selection > Extract X/Y
- In AxisRotator.R change Axis Rotator Facade > Lateral Axis to RightTeleport.X and Axis Rotator Facade > Longitudinal Axis to RightTeleport.Y
- Disable ThubmstickTouched.R, ThumbstickPressed.R, and ThumbmstickPosition.R by selecting them and unchecking them in the inspector
- On TeleportCurved.R change Pointer Facade > Activation Action to InputHandlers > TeleporterActivation.R and Pointer Facade > Selection Action to InputHandlers > TeleporterSelection.R
- Now test with the right controller only
Snap Turns on the Left Controller
- Disable TeleportCurved.L, InputHandlers > ThumbstickTouched.L, ThumbstickPressed.L, and AxisRotator.L
- Search “axestovector3” in the asset finder and drag the AcesToVector3 object to the scene Hierarchy
- In AcesToVector3 change Axes To Vector 3 Facade > Axis Usage Type to Directional
- Drag InputHandlers > ThumbstickPostion.L>ThumbstickX.L to Axes To Vector 3 Facade > Lateral Axis and InputHandlers > ThumbstickPostion.L>ThumbstickY.L
- Set the Axes To Vector 3 Facade > Lateral Speed Multiplier to 45 and the Longitudinal Speed Multiplier to 0
- Search “vector3cache” in the asset finder and add Vector3Cache to AxesToVector3
- Add a list item to Axes To Vector 3 Facade > Events and drag AxesToVector3 to the object and change the function to Vector3Cache.CachedData
Fade The Screen on Snap
- Search “cameracoloroverlay” in the asset finder and add CameraColorOverlay.cs to AxesToVector3
- On AxesToVector3 > Vector 3 Cache > Modified drag AxesToVector3 to the target and select CameraColorOverlay.Blink
- Drag TrackedAlias > Aliases > SceneCameras to AxesToVector3 > Vector 3 Cache > Camera Validity
- Search “teleportfade” in the asset finder and drag TeleportFade shader to AxesToVector3 > Vector 3 Cache > Overlay Material
- Set AxesToVector3 > Vector 3 Cache > Remove Duration to 0.5
- Create a new object called “SnapRotator”
- Search “vector3tovector2” in the asset finder and add Vector3ToVector2.cs to SnapRotator
- Then search “vector2tovector3” in the asset finder and add Vector2ToVector3.cs to SnapRotator
- On AxesToVector3 > Axes To Vector 3 Facade > Events add a list item and drag the SnapRotator to the target. Set the function to Vector3ToVector2.DoTransform
- Add a list item to SnapRotator > Vector 3 To Vector 2 > Transformed. Drag SnapRotator to it’s target and set the function to Vector2ToVector3.DoTransform
- Set SnapRotator > Vector 3 To Vector 2 > Coordinate Map to X To Y And Y To X Exclude Z
- Search “transformeu” in the asset finder and drag TransformEulerRotationMutator.cs to SnapRotator
- Add a list item to SnapRotator > Vector 2 To Vector 3 > Transformed and SnapRotator to it’s target and set the function to TransformEulerRotationMutator.DoIncrementProperty
- In SnapRotator > Transform Euler Rotation Mutator > Target drag Aliases > PlayAreaAlias . Check Use Local Values and make sure Mutate On Axis is only set to Y
Disable Snap-to-Floor
- Disable Teleporter.Instant > Internal > SnapToFloor
Prevent Wall Clipping
- Search “collisionfa” in the asset finder and drag the CollisionFader under TrackedAlias > Aliases > HeadsetAlias
- Drag Aliases > SceneCameras into CollisionFader > Camera Color Overlay > Camera Validity
- Add 2 new layers to CollisionFader. One called “FadeCamera” and another called “FadeOut”
- Set the CollisionFader layer to FadeCamera
- Add Environment > PlayArea > Cabinet > cabinet to the FadeOut layer
- Go to Project Settings > Physics and uncheck all FadeCamera boxes
- In OVRCameraRig > TrackingSpace Select LeftEyeAnchor, CenterEyeAnchor, and RightEyeAnchor and set Camera > Clear Flags to Solid Color and select black