So our iOS game is set to portrait mode only. However, we still have to query the devices tilt for certain screens. We don't want the entire game to rotate, just specific ui pieces. For our initial test case it seems to work OK.
I hold the device straight up prior to launching the game. When the game is launched we grab the current rotation like so:
http://1drv.ms/18iakeu
The rotation displayed is around (P=0,Y=0,R=0). As I rotate the device to the left it centers around (P=-45, Y=-90, R=0) and when I rotate it to the right it will center around (P=45, Y=90, R=0).
Using that information I'm simulating a rotation on some of our UI objects based on the Yaw. (-20 to +20) is the default, while (-100, -80) represents left and (80,100) represents right.
Now, our second test case which fails goes as follows. Close the game completely, rotate the device 90 degrees to the left (so it is horizontal). Launch the game. Remember the game is set to only run as Portrait so the user will naturally rotate the device to see it. The issue though is that the game somehow initialized the tilt information prior to device being rotated by the user. So when the user rotates the device to look at it the rotation is no longer around (P=0, Y=0, R=0) but rather (P=0, Y=45, R=0). Rotating it to the left centers it around (P=90, Y=90, R=0) and to the right centers it around (P=25, Y=90, R=0) which is a bit more baffling..
So, how can we tell the engine to re-calibrate while the user holds it straight up or how can we compensate for this situation in general?
Thanks, -jv
I hold the device straight up prior to launching the game. When the game is launched we grab the current rotation like so:
http://1drv.ms/18iakeu
The rotation displayed is around (P=0,Y=0,R=0). As I rotate the device to the left it centers around (P=-45, Y=-90, R=0) and when I rotate it to the right it will center around (P=45, Y=90, R=0).
Using that information I'm simulating a rotation on some of our UI objects based on the Yaw. (-20 to +20) is the default, while (-100, -80) represents left and (80,100) represents right.
Now, our second test case which fails goes as follows. Close the game completely, rotate the device 90 degrees to the left (so it is horizontal). Launch the game. Remember the game is set to only run as Portrait so the user will naturally rotate the device to see it. The issue though is that the game somehow initialized the tilt information prior to device being rotated by the user. So when the user rotates the device to look at it the rotation is no longer around (P=0, Y=0, R=0) but rather (P=0, Y=45, R=0). Rotating it to the left centers it around (P=90, Y=90, R=0) and to the right centers it around (P=25, Y=90, R=0) which is a bit more baffling..
So, how can we tell the engine to re-calibrate while the user holds it straight up or how can we compensate for this situation in general?
Thanks, -jv
Comment