Skip to main content

First Person Controller

The HoloMIT SDK’s movement module allows users to control their avatar using Unity’s CharacterController and the New Input System, with built-in handling for XR device presence.


Overview

  • Translates 2D input vectors into 3D movement relative to the player’s orientation.
  • Automatically disables when an XR headset is detected or when the local player is inactive.
  • Offers configurable parameters for speed and enable/disable behavior.

Requirements

  • Unity 2022.3 LTS or later
  • CharacterController component on your player GameObject
  • New Input System package enabled
  • XR Interaction Toolkit for XR headset detection

Setup

  1. Add the PlayerMovement component to your player prefab.
  2. Ensure a CharacterController is attached to the same GameObject.
  3. Assign your movement InputAction (Vector2) to the Move Action field.
  4. Add the PlayerManager component to your player prefab and assign its cam (camera) reference.

Exposed Parameters

PropertyTypeDescription
speedfloatMovement speed multiplier (default: 5).
forceNoMovementboolWhen true, disables all movement logic.
moveActionInputActionReferenceInput action for reading the Vector2 movement.

Usage

  • Adjust Speed: Modify the speed field in the inspector to set movement pace.
  • Temporarily Disable: Toggle forceNoMovement in your code (e.g., during UI menus) to halt movement.
  • XR Auto-Disable: Movement deactivates automatically when XRSettings.isDeviceActive is true.
  • Ownership Check: Movement only applies if the player’s camera GameObject is active.

Known Limitations

  • No built-in gravity or jump support.
  • Movement is frame-rate dependent; consider adding gravity handling.
  • Only respects the default CharacterController collision settings.