# calibrate the tilt for level

Get help using Construct 2

### » Wed Jan 08, 2014 5:48 am

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
B
8
S
3
G
1
Posts: 87
Reputation: 1,493

### » Wed Jan 08, 2014 9:03 pm

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.

B
6
S
2
Posts: 151
Reputation: 1,366

### » Wed Jan 08, 2014 9:19 pm

I don't think there is any need for trigonometry, but one can make it as hard as one wants.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

### » Fri Jan 10, 2014 3:03 am

#Facts
B
6
S
2
Posts: 151
Reputation: 1,366