- Home /
Converting Android Axis to Unity Axis
I'm receiving input from SensorManager.getRotationMatrix() and trying to apply this to my Unity camera while the device is in Landscape mode held out in front (with the screen pointing at me), so that when I hold it like this, I will be looking along the z axis in Unity
The problem is the Android axis is x:right, y:forward, z:up. Unit is x:right, y:up, z:forward
sounds simple, but if you remap the device axis so x is up (it faces up when in landscape mode), then y is left and z is backward. You can remap the x and y axis only, so remappng x as AXIS_MINUS_Y and y as AXIS_X only gets you so far, z is still pointing backwards.
Android only gives you a rotation matrix, which I convert to a Matrix4x4 and then use Quaternion.LookRotation(). I did find a method that converts a matrix to a quaternion, but that gave the same result.
I have had moderate success, the best was when I got pitch matching (rotating the device around its local y axis translating to rotation around the unity x axis), but the other two rotations were reversed (yawing around the device x axis (which is currently point up) resulted in roll in unity, and rolling the device around its z axis resulted in yaw in unity).
I am not good at this kind of thing, I'd really appreciate some help.
Your answer
Follow this Question
Related Questions
Unity touchpad not working to rotate an object 1 Answer
Change rotation axis when importing from Maya 2 Answers
2D : Rotation of Object With x-y Axis 2 Answers
A node in a childnode? 1 Answer