Type Number Event gyroscope Revision Release 2024.3703 Keywords gyroscope, yRotation See also event.xRotation event.zRotation event.deltaTime
The rotation rate around the device’s
You can convert radians to degrees via the following formula:
degrees = radians * (180 / pi)
-- Called when a new gyroscope measurement has been received local function onGyroscopeDataReceived( event ) -- Calculate approximate rotation traveled via delta time -- Remember that rotation rate is in radians per second local deltaRadians = event.yRotation * event.deltaTime local deltaDegrees = deltaRadians * (180/math.pi) end -- Set up the above function to receive gyroscope events if the sensor exists if system.hasEventSource( "gyroscope" ) then Runtime:addEventListener( "gyroscope", onGyroscopeDataReceived ) end