event.yRotation

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

Overview

The rotation rate around the device's y-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.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