How does InputObject.Delta work?

I’m trying to run code when a player on mobile shakes their device. I plan to do this by checking if the delta value of UserInputService:GetDeviceRotation() is over a certain threshold.

I know that the delta describes the change of position in this case, but I don’t know how to use it. In what manner does it describe the difference in position, and should I use it in this case?

1 Like

For example, if the devices rotation was 90 degrees, than it changed to 60 degrees for examples, the delta rotation or in other words change in rotation would be 30.
We can check if the delta rotation is quite a big gap, so if like it turned 30 degrees we would do something

UIS:GyroscopeEnabled()

game:GetService("RunService").RenderStepped:Connect(function()
   local change = UIS:GetDeviceRotation()
   if change >= 30 then
      --do something
   end
end)

Also :GetDeviceRotation() won’t work unless you call :GyroscopeEnabled().

2 Likes

I am pretty confident that UserInputService:GetDeviceRotation() returns the delta rotation and the CFrame of the device. And as @starmaq explained, delta is just change in/of.

Edit: Check this article out for more assistance.

2 Likes

Isn’t GyroscopeEnabled a property? I already check that it’s true.

Yeah it’s also a property, but there is a method to enable it as well.

And and also, UIS has an event called DeviceRotationChanged which would fire when the device’s rotation has changed which is better to use than a RenderStepped. It also has a paramater of the change in rotation so you can even check if the change is too big or a little change.

UIS.DeviceRotationChanged:Connect(change)
 if change >= 30 then
   
 end
end)
1 Like