getcontrollermotion
getcontrollermotion(controller?) reads the motion sensors of a connected controller, or nil if the controller is missing or doesn't have motion sensors.
local motion = getcontrollermotion()
if motion and motion.hasAttitude then
local q = motion.attitude -- {x, y, z, w}
end
Parameters
controller(number, optional): the controller index, starts at 1
Returns
attitude(table): quaternin,{x, y, z, w}rotationRate(Vector3): radians per secondacceleration(Vector3): includes gravity, in ghasAttitude(boolean)hasRotationRate(boolean)
Notes
Keep in mind that rotation DRIFTS over time, so you will need to have some kind of recentering option.