- Home /
Android align gameobject to smartphone rotation and north pole
Hi there, this is my first unity question, so I'm trying to create a 3D compass app for android in unity, the compass needs to rotate arount the Y-Axis to point to the north pole (working) and it needs to be able to rotate around the X-Axis if I look up/down with my phone to look ontop of the compass or below it (working), but whenever I try to use both functionalities at the same time it looks like the image below. It shows the north pole, but I can't look ontop of it.
//x rotates so i can see ontop or below the compass, y turns to the north pole. But both wont work together.
compass.transform.localEulerAngles = new Vector3(-attitude.eulerAngles.x,-compassNorthRotation,0);
Answer by MrElektronz · Jun 02 at 12:53 PM
Oh well I fixed my problem, parented the compass to another gameobject and changed the X-Axis of the parent and the local Y-Axis of the child.
Your answer
Follow this Question
Related Questions
Smooth Follow Camera Rotate on Z-Axis? 2 Answers
How to clamp character rotation on Y and X axis? 1 Answer
Limiting X-Axis rotation to 90 degrees and -90 degrees 1 Answer
LookRotation or euler angle object rotation towards 1 Answer
How can I make player rotation control camera's x rotation and mouse control it's y rotation? 1 Answer