PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

GetDeviceRotation

This function returns an InputObject and a DataType/CFrame describing the device’s current rotation vector.

This is fired with an InputObject. The Position property of the input object is a Enum/InputType|Enum.InputType.Gyroscope that tracks the total rotation in each local device axis.

Device rotation can only be tracked on devices with a `UserInputService/GyroscopeEnabled|gyroscope.

As this function fires locally, it can only be used in a LocalScript.

Returns

Return Type Summary

A tuple containing two properties:

  1. The delta property describes the amount of rotation that last happened
  2. The CFrame is the device’s current rotation relative to its default reference frame

Code Samples


Print Device Rotation

This example prints the current CFrame of a players device. Note that this will only work as expected if the player’s device has an enabled gyroscope. If not, the example prints:

Cannot get device rotation because device does not have an enabled gyroscope!