- Home /

# Gyroscope eulerangles giving weird angles

Hi, im currently working on a project for which I use the gyroscope orientation to move an object in a 2D Space. Essentially, when the phone rotates on the local x-axis, the object moves from Point A to Point B. When the phone has completed a full 360°, the object arrives at Point B. The maths behind that is no problem, I take the distance the object has to travel and divide it by 360 and get the amount that it needs to move per degree. Then I simply subtract the initial rotation values from the current rotation in Update() and multiply the difference with the outcome of the previous calculation.

In my case its:

1118/360 = 3.105555555555556

Then I subtract the difference of the x-axis rotations and multiply that with 3.105555555555556 and move the object by the result.

Now that would work fine, but I have a problem with the rotations. I am using `transform.localRotation = gyroscope.attitude * rot;`

with rot being `rot = new Quaternion(0, 0, 1, 0);`

to get my phones orientation and to move my camera object accordingly. That works fine, my camera rotates the way I want it and im happy with it.

The problem is, that when I convert that Quaternion into eulerAngles, so that I have the values I can read and use to calculate the amount I have rotated (as in calculation 2.), I get really wonky values. Instead of getting 0-360° (A), the values in the inspector are (B) 0 to 90 to 0 to -90 to 0. And the values when I Debug.Log the rotation are even weirder, they go from 0 to 90 to 0 and then to 360 to 270 and then to 360 (C). Perhaps this image can help understand that.

This is really frustrating, because I cannot do any calculations with those numbers as calculation 2. is based on the degrees steadily increasing if I move in a circle. Is there anyway I can solve this issue and get a 0-360° rotation from my gyroscope.attitude? Or instead can you think of a different way to solve this altogether? Any help is appreciated.

Thanks a lot!

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.

### Follow this Question

### Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Limit Rotation Issues 1 Answer

What is wrong with my Counter Script? (C#) 1 Answer

Scaling related to damage 2 Answers