Skip to content

XR ​

An XR project is for headsets: virtual reality, where your world fills the headset, and mixed reality, where the real room shows through and your content sits in it. Players look around, move, grab and throw things with tracked hands or controllers, and can play together in the same room or online.

Use it for games, training, virtual showrooms, social spaces, walkthroughs and tabletop games in a real room.

An XR project open in the editor

Virtual or mixed reality ​

When you create an XR project, you choose how its first scene starts:

  • Virtual Reality: your environment fills the headset, with a teleport area for moving around.
  • Mixed Reality: passthrough shows the real room, objects collide with real floors and walls, and the player walks their own space. Tick Shared table for players in one room to start with multiplayer on and a board with pieces both players can move.

This only sets up the first scene. You can switch at any time with Passthrough on the XR Rig, and a game can switch between the room and VR while it runs (see Mixed Reality).

What's in the scene ​

A new XR project starts with:

  1. XR Rig: the player. It carries the camera and handles moving around, the floor height and comfort settings.
  2. XR Interactor: the player's hands or controllers, with pointer rays for pointing and grabbing.
  3. Teleport Area (virtual reality): a surface players can teleport onto.

You add more from Add Object → XR (XR Rig, XR Interactor, Teleport Area) and Add Component → XR (XR Rig, Teleport Area, XR Interactor, XR Interactable, World Anchor, Hand Poses).

Supported headsets ​

  • Meta Quest (Quest 2, 3, 3S, Pro): hands and controllers, passthrough, the full feature set.
  • Pico: hands and controllers.
  • Android XR: hands first.
  • Apple Vision Pro: look and pinch only, no controllers, and virtual reality only (no passthrough on the web).

Workflow ​

  1. Set up the XR Rig: how players move, where the floor is and comfort settings, in the inspector.
  2. Add content: models, lights and objects. Everything is placed at its world position.
  3. Make things grabbable: give an object XR Interactable, and a Physics component with a Dynamic rigidbody if it should be thrown.
  4. Mark where players can teleport: add Teleport Area to floors and platforms.
  5. Choose hands or controllers on the XR Interactor.
  6. Script interactions with Behaviour hooks such as onGrab and onRelease (below).
  7. Test on your headset: open the Preview tab. It sends the game to your headset over Wi-Fi and shows what the headset sees, its console and its frame rate in the editor. See Headset testing.
  8. Ship it: Publish gives you a link that opens in the headset's browser, and App → Meta Quest turns the published game into a Quest app. See Building apps.

Core components ​

XR Rig ​

The player's movable origin. Its settings:

  • Tracking Origin: Floor level (y = 0 is the real floor, for standing games) or Eye level (y = 0 is where the headset started, for seated or cockpit games).
  • Locomotion: Teleport (point and jump, the most comfortable), Smooth (thumbstick movement, with Move Speed) or None (no movement).
  • Snap Turn with Turn Angle: turn in steps instead of smoothly, which makes far fewer people feel sick.
  • Eye Height.
  • Teleport Arc: Color, Blocked Color and Thickness.
  • Mixed Reality: Passthrough, then Occlusion (real things hide virtual ones), Room Physics (None, Auto, Flat surfaces or Full room scan), Show Room, Surface Aiming, Anchors and Start In (Your room or VR).

Getting the floor right

"I spawned inside the floor" usually means the wrong tracking origin. If your content sits on y = 0, use Floor level so players stand on it.

XR Interactor ​

What players see as their hands and how they point:

  • Type: Both (whatever the headset reports), Hands, Controllers or None (custom only).
  • Preset for tracked hands: Default, Ghost, Neon, Skeleton or Custom, with Color, Opacity and Glow.
  • Show Ray: When interacting (only when pointing at something you can use), Always or Never, with Ray Color and Ray Thickness.

XR Interactable ​

Makes an object respond to hands and pointers:

  • Pointable and Grabbable.
  • Grab: Reach (Both, Physical (touch) or Distance (ray)), Grab Radius, At Distance (Snap to hand or Move in place) and Gesture (Any, Pinch or Full grip).
  • Hands: Pass between hands, Two hands or One hand only. With two hands, Second Hand either Aims the object (like a rifle) or Resizes only, and Resize with Min Size and Max Size.
  • Attach Points: where hands hold it, each limited to a Hand (Either, Left, Right) and a Role (Either, Main hold, Support hold).
  • Release: Apply Velocity and Velocity Scale, so throws carry the hand's motion.
  • Hover: Feedback (Outline, Grow, Outline + grow or None) so players can see what they're pointing at.

Teleport Area ​

Marks a surface players can teleport onto. Teleport only lands on surfaces that have it.

  • Shape: Plane (with Width and Depth) or Circle (with Diameter), in metres.
  • Enabled: turn it off without removing it.

Grabbing and throwing ​

To make an object throwable:

  1. Add XR Interactable and keep Grabbable on.
  2. Add Physics with a Dynamic rigidbody.
  3. Keep Apply Velocity on (it is by default).

While the object is held, its physics pauses and it follows the hand. On release it takes the hand's recent motion, so throws match the gesture.

ts
import { Behaviour, type XrInputState } from "@relu-interactives/spatial-ecs";

export default class Basketball extends Behaviour {
  onGrab(input: XrInputState) {
    console.log("picked up by", input.handedness);
  }

  onRelease(input: XrInputState) {
    // The throw velocity is already applied: react to it here.
    console.log("thrown!");
  }
}

Scripting interactions ​

HookWhen it runs
onSelectStart(input)Trigger pressed or fingers pinched
onSelectEnd(input)Released
onGrab(input)This object was picked up
onRelease(input)This object was let go
onSecondaryGrab()A second hand grabbed it (two-hand mode)
onSecondaryRelease()The second hand let go
onHandPoseStart(event)A hand pose you set up began
onHandPoseEnd(event)That pose ended
onXRSessionStart(capabilities)The headset session started, with what it allows
onXRSessionEnd()The session ended

See VR, Grabbing and Hand Poses for full patterns.

Playing together ​

Turn on multiplayer in World Config → Multiplayer and players join the same game online, or in the same room. In mixed reality, two players in one room can line up their worlds by touching the same two table corners (colocation). See Multiplayer, the engine's Multiplayer guide and Colocation.

Apple Vision Pro ​

  • Only hands: look at an object and pinch to select it.
  • The pointer ray appears while you pinch, not before.
  • There's no grip squeeze, so set Gesture to Pinch or Any, never Full grip.
  • Safari on Vision Pro has no passthrough for the web, so projects run in virtual reality.

Tips ​

Comfort ​

  • Start with Teleport and Snap Turn. They suit the most people.
  • Use Floor level for standing games.
  • Test on a real headset: comfort can't be judged on a screen.

Performance ​

  • Headsets need a steady, high frame rate or players feel ill. Quest games aim for 90 frames a second and settle at 72 when they can't hold it.
  • Heavy models are the usual cause of a slow headset game: keep props and characters light and cut down the number of separate parts.
  • Watch Stats while you play on the headset, and profile there: see Headset testing and Profiler.

Interaction design ​

  • Show hover feedback, so players know what they're pointing at.
  • Allow both touch and ray reach for things people need to pick up.
  • Use attach points for tools and weapons, so hands land in the right place.
  • Mark teleport areas deliberately: not every surface should be walkable.

Cross-platform ​

  • Set the XR Interactor to Both: Quest players switch between controllers and hands, and Android XR starts with hands.
  • Support pinch: Vision Pro needs it.