VR deprecated
Head-mounted display + motion-controller integration. Two-step lifecycle: detect, then link.
local VR = import("VR")
if not VR.IsVrPresent() then return end
local cam = VR.LinkVRView()
cam.BodyCframe = CFrame.new(Vector.new(0, 1.6, 0))
cam.HeadMoved:Connect(function(cf) print(cf.Position) end)
local pads = cam:GetControllers()
pads.Right.OnInput:Connect(function(name, value, state)
if name == "Trigger" and state == "Begin" then
pads.Right:Vibrate(0.05)
end
end)
VR API
True if a VR runtime is installed on this host. Detects SteamVR / Oculus / OpenXR via env vars + Windows registry. Doesn't require a headset to be currently plugged in, it's the "should we offer VR in the menu" check.
Hand the engine camera over to the VR pipeline. Calling while already linked is safe; returns a fresh handle observing the same state.
BodyCframe is world-relative, where the player's VR
rig sits. HeadCframe is the headset pose; the engine
composes Body &compose; Head onto the active 3D camera each
frame, so existing BasePart / Renderable code keeps working without any
VR-aware changes.
VRCamera
Properties
Player body pose. Writable, set this to teleport, snap-turn, or move the rig.
Headset refresh rate in Hz (90 default; runtime usually reports 72/90/120/144).
Proximity-sensor state. Older HMDs always report true.
Interpupillary distance in metres. Default 0.063.
Fires "Connected" / "Disconnected"
/ "Worn" / "Removed".
Methods
Release the engine camera and tear down the VR session. Idempotent.
Re-anchor the play space so the current head pose becomes the origin facing +Z.
Chaperone / guardian dimensions in metres. (0, 0) when not reported.
Fade the headset view to/from a solid colour. Useful for teleport transitions.
Returns the same logical controllers on every call (the userdata is freshly allocated but the underlying state is shared) so signals connected on one handle still fire when the runtime reports input.
VRController
Properties
Linear velocity in metres/second. Useful for throwing physics, multiply by mass at release.
Angular velocity in degrees/second around X / Y / Z.
Cached 0..1 trigger pull from the most recent OnInput event.
x = -1..1 horizontal, y = -1..1 vertical, z = 0.
(name, value, state). Names include
"Trigger", "Grip", "A",
"B", "ThumbstickX",
"ThumbstickY", "Menu", etc.
Methods
Fire a haptic pulse. Frequency in Hz (typical 160–320), amplitude 0..1; both default to a "click" pulse if omitted. Returns true when scheduled. Multiple overlapping calls layer additively.