Skip to content

controller-movement

The controller-movement component enables smooth locomotion in VR using controller thumbsticks, allowing users to navigate through virtual environments with intuitive dual-controller movement.

Example

Below is an example of setting up controller movement in a basic scene:

Props

PropertyTypeDefaultDescription
mainHandstring"left"Controller used for movement ("left" or "right")
speednumber2Movement speed in meters per second
rotationSpeednumber60Rotation speed in degrees per second
modestring"controller"Movement direction mode ("head" or "controller")
smoothingnumber0.1Movement smoothing factor (0-1, higher = more smoothing)
deadzonenumber0.2Thumbstick deadzone (0-1, ignores small stick movements)

How It Works

  1. The component uses a dual-controller approach for VR locomotion:
    • The main hand (typically left) controls forward/backward movement and strafing
    • The off hand (opposite of main hand) controls rotation
  2. Movement is determined by thumbstick direction:
    • Forward/backward: Up/down on the main hand thumbstick
    • Strafing: Left/right on the main hand thumbstick
    • Rotation: Left/right on the off hand thumbstick
  3. The movement direction can be based on either:
    • Head direction (where you're looking)
    • Controller direction (where the main controller is pointing)
  4. Movement is applied to the camera rig entity, with smooth acceleration and deceleration

Movement Controls

ThumbstickDirectionAction
Main HandUpMove forward
Main HandDownMove backward
Main HandLeftStrafe left
Main HandRightStrafe right
Off HandLeftRotate left
Off HandRightRotate right

Combining with Other Movement Options

For maximum accessibility, combine smooth locomotion with teleportation using the controller-teleport component:

html
<a-entity id="rig" position="0 1.6 0" controllers>
  <a-camera></a-camera>
  <!-- Smooth movement with left hand -->
  <a-entity controller-movement="mainHand: left"></a-entity>
  <!-- Teleportation with right hand -->
  <a-entity controller-teleport="hand: right"></a-entity>
</a-entity>

This gives users options for both smooth locomotion and teleportation, accommodating different preferences and comfort levels. Smooth movement is often preferred for precision navigation, while teleportation can reduce motion sickness for some users.