PcoWSkbVqDnWTu_dm2ix
The Developer Hub is now deprecated and information on this page may no longer be accurate. To see our new and improved documentation, please click here. You can read more about the future of documentation here.
Collapse Sidebar

GetUserCFrame

The GetUserCFrame function returns a DataType/CFrame describing the position & orientation of a specified virtual reality (VR) device.

This function should be used when implementing VR compatibility into a game to obtain and track the movement of a connected VR device.

By using the function, players can implement features such as re-positioning the user’s in-game character corresponding to the location of a connected VR device. This can be done by changing the CFrame of the user’s in-game character to match the CFrame of the specified VR device using the UserCFrame enum and CFrame value arguments passed by the event.

The VRService service also provides an event /VRService/UserCFrameChanged that automatically fires when the CFrame of connected VR device changes - so long it is used in a LocalScript.

This can also be used alongside the several /UserInputService VR functions and events.

Since /VRService only runs client-side, this function will only work when used in a /LocalScript.

Parameters

Name Type Default Description

The specified UserCFrame.

Returns

Return Type Summary

Code Samples


VRService:GetUserCFrame

This example prints the specified Enum and its current CFrame value when Enum.UserCFrame.Head is the specified VR device.