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

GetDeviceAcceleration

The GetDeviceAcceleration function determines the current acceleration of the user’s device. It returns an InputObject that describes the device’s current acceleration.

In order for this to work, the user’s device must have an enabled accelerometer. To check if a user’s device has an enabled accelerometer, you can check the UserInputService/AccelerometerEnabled property.

If you want to track when the user’s device’s acceleration changes instead, you can use the UserInputService/DeviceAccelerationChanged event.

Since it only fires locally, it can only be used in a LocalScript.

Returns

Return Type Summary

An InputObject that describes the device’s current acceleration.


Code Samples


UserInputService:GetDeviceAcceleration

This example checks if a user’s device has an enabled accelerometer. If it does, the example prints the current acceleration of the device. If not, the example prints:

Cannot get device acceleration because device does not have an enabled accelerometer!