getting this error “game.lua Line: 319 Attempt to perform arithmetic on local ‘gy’ (a nil value)”
using this code :
local gy, gz = event.yGravity, event.zGravity local len = math.sqrt(gy\*gy+gz\*gz) \* (gz \< 0 and -1 or 1) cos\_delta = gz / len sin\_delta = -gy / len
i am trying to set the accelerometers 0 point to the users position/the angel he is holding it
is executed outside of your onTilt function. At that point your app doesn’t know what event is and it’s certainly not populating the xGravity, yGravity and zGravity values. You have to do these calculations inside your onTilt() function. You will have to have a flag indicating that you need to save the first values and the first time onTilt() is called, then you can set your baseline.
is executed outside of your onTilt function. At that point your app doesn’t know what event is and it’s certainly not populating the xGravity, yGravity and zGravity values. You have to do these calculations inside your onTilt() function. You will have to have a flag indicating that you need to save the first values and the first time onTilt() is called, then you can set your baseline.