godot-xr
Installation
SKILL.md
XR with OpenXR (4.7)
Headless runs can't start XR. Code paths still run (the interface reports not initialized), so headsets are needed for real tests.
Setup
- Renderer: Mobile (recommended for XR in 4.7, desktop and standalone). Compatibility works for low-end standalone. Forward+ works on PCVR but isn't optimized for it.
- Project Settings:
xr/openxr/enabled = trueandxr/shaders/enabled = true. The default action map (xr/openxr/default_action_map) has 4 profiles in 4.7: generic controller, touch controller, Pico 4 and hand interaction. Add profiles for other devices in the action map editor. - Standalone Android headsets (Quest, Pico, Android XR, which is day-one in 4.7) need the Godot OpenXR Vendors plugin (Asset Store) and an Android export preset with XR mode = OpenXR plus the vendor's loader enabled. Steam Frame and PCVR go through SteamVR's OpenXR runtime.
- Scene rig:
XROrigin3D→XRCamera3D+XRController3D(tracker = &"left_hand"/&"right_hand"). One origin per scene. Move the player by moving the origin, never the camera.
Startup (see the reference)
var xr := XRServer.find_interface("OpenXR") → xr.is_initialized() (auto-initialized when OpenXR is enabled) → get_viewport().use_xr = true. Turn VSync off (DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)), because the headset paces frames. Match Engine.physics_ticks_per_second to the headset refresh rate (display_refresh_rate), so held objects don't jitter. Listen for the OpenXR session signals: session_begun, session_visible, session_focussed (resume), session_stopping, pose_recentered.
Input
- Use actions from the action map:
controller.is_button_pressed(&"trigger_click"),get_float(&"trigger"),get_vector2(&"primary")(thumbstick), plus thebutton_pressed/button_releasedsignals. Action names come from the action map, not hardware buttons. - Haptics:
controller.trigger_haptic_pulse(&"haptic", frequency, amplitude, duration_sec, delay_sec). - Hand tracking:
XRHandModifier3Don a hand skeleton (OpenXR hand tracking extension). The hand interaction profile gives pinch and grasp as actions. Body tracking usesXRBodyModifier3D. - Desktop and UI interaction: render 2D UI in a
SubViewporton a quad and raycast with the controller, or use Godot XR Tools' pointer and viewport-2D-in-3D (addon).