Hi! I’m making a game with flying pigeon on android with accelerometer contol, and i have a trouble with rotating it in local space. Everything is allright when i’m flying straight and want to turn up or down (around X axis in local space).
When i want to turn left or right, firstly i need to lean to one side (rotate around z axis - blue arrow), and then to rotate around X axis in local space (red arrow).
But when i rotate around X axis in local space, it turns up, just as in world space! (red arrow, wanted rotation - green arrow)
Here is code i use to rotate it:
transform.localEulerAngles = new Vector3 (-Input.acceleration.z * rotationAngle,
transform.localEulerAngles.y,
-Input.acceleration.x * rotationAngle);
It gives the same result as using transform.eulerAngles
and transform.localRotation gives the same result as transform.rotation
transform.Rotate with local space works properly, but it’s not suitable for accelerometer control.
What’s the problem?