Skip to main content
Namespace: MolcaSDK.VR
File: Assets/_MolcaSDK/_VR/Scripts/VRPlayerManager.cs
Attach to the XR Origin (XR Rig) root. Uses a static Instance; resolves VRSubsystem after RuntimeManager initialization.

When to use

Use VRPlayerManager when you need a single place to:
  • Read player ground position (GetGroundPosition — head XZ with XR Origin Y).
  • Enable or disable all XR Interaction Toolkit locomotion providers together (teleport, move, snap turn, etc.), e.g. during precision Grab step work.
  • Access left/right VRControllerVisual from static properties for haptics or visuals.

Inspector setup

After WaitForInitialization, the manager caches providers and sets IsLocomotionEnabled from the first provider’s enabled state (or false if none).

Code

Disable locomotion for a precision step, then restore:
Listen for EventConstants.VR.LocomotionStateChanged via EventDispatcher if other systems need to react (payload type LocomotionStateChangedData, property IsEnabled).

API (key members)

Troubleshooting

  • “Instance not found” / null static access — Only one VRPlayerManager should exist on the active rig; Awake assigns Instance. Ensure the rig is active before calling static helpers from arbitrary objects.
  • Locomotion toggle does nothing — Confirm LocomotionProvider components live under the same GameObject hierarchy (auto-discover) or are assigned in manual list. Check the Console for “No locomotion providers” warnings.
  • VRSubsystem not foundRuntimeManager prefab must include VRSubsystem; wait until after subsystem init (manager waits in Start).
  • Wrong ground heightGetGroundPosition uses xROrigin.transform.position.y; verify XROrigin reference and floor / tracking setup.

Unity Editor

XR Origin root with VRPlayerManager + locomotion components.

VRPlayerManager in Unity Inspector

VRPlayerManager on XR Origin