event.zRotation

Type Number
Event gyroscope
Revision 2017.3060
Keywords gyroscope, zRotation
See also event.xRotation
event.yRotation
event.deltaTime

Overview

The rotation rate around the device's z-axis in radians per second.

Gotchas

You can convert radians to degrees via the following formula:

degrees = radians * (180 / pi)

Example

-- 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.zRotation * 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