# calibrate the tilt for level

0 Favourites
• 4 posts
• hi guys...im trying to figure out what the math should be to calibrate one axis to "level".

lets say the error in the measurement is 2 degrees....andi have a surface that is unknown levelness....

if i take a touch beta measurement on that surface, then rotate the phone 180 degrees and take a second measurement, i get the error shouldwork out to be :

error = (measurement1+measurement2)/2

then subract the error from the touchb.beta and you should have the anglular measurement relative to actual level.

but its not working for some reason and im not sure why

any ideas?

thansk

Dan

• Looks like you'll need some trigonometry. The three Trigonometric functions are sine, cosine and tangent. In C2 their system expressions are cos, sin , tan // for inverse: acos , asin , atan .

I'm in the process of trying to set the accelerometer's zero point to the users phone's position/angle he is holding it on start of layout. There's alot of trial & error involved but the purpose of it is to allow the player to play the game without compromise to the how they want to hold the phone to control their player since my game is 8 direction tilt based.

Try working with Touch.Acceleration expressions and comparing two values. You can also create a variable & subtract from that every time the player moves.