codeAPI Reference

Sandbox.VrAnchor

calendar_today May 3, 2026 schedule ~1 min read person patrickjr verified 50

Sandbox.VrAnchor

Locks VR player position.

Overview

VrAnchor locks the player's playspace to a GameObject's transform. Essential for seated VR, vehicles, and room-scale setup.

Setup

CSHARP
[RequireComponent]
public VrAnchor Anchor { get; set; }

Usage

CSHARP
// The VR player's view is locked to this GameObject
// Moving the GameObject moves the player

// Vehicle VR - player moves with vehicle
public class Vehicle : Component
{
    [RequireComponent]
    public VrAnchor Anchor { get; set; }
    
    protected override void OnUpdate()
    {
        // Player automatically follows vehicle
        WorldPosition += Velocity * Time.Delta;
    }
}

Seated Experience

CSHARP
// Lock player to chair position
var chair = new GameObject("Chair");
chair.WorldPosition = seatPosition;
chair.Components.Create<VrAnchor>();

// Player's view is now at chair height/position

Recentering

CSHARP
// Recenter playspace to current anchor position
Anchor.Recenter();

Properties

PropertyDescription
LockHeadLock head position
LockHandsLock hand positions
Was this helpful?