# Obtain angle from given rotation

Hi there!

I’ve been searching around the Community and I didn’t find a suitable response for me, or at least I cannot get the possible solutions working on my project.

I want to simulate wind on a 2D environment, making this wind affecting an object. I get a random angle between 1 and 360 and compare it with the angle of the object. I’m obtaining this angle with:

``````Quaternion.Angle(transform.rotation, Quaternion.identity)
``````

The problem is that this value varies between 0 and 180, unsigned, no matter the rotation of the object. I need to know the sign because if the angles are the same, the object reaches maximum speed in the direction it is facing, stopping if they are contrary.

How can I obtain the object’s angle having its rotation?

Thanks!

Hi if you are in 2d, only angle you need to take care is you Euler Z. It it angle relative to Right Vector

``````    float angle = transform.rotation.eulerAngles.z; //0 - 360 comapring to Vector2.right anti clockwise
float signedAngle = angle > 180 ? angle - 360f : angle; //-180, 180 comapring to Vector2.right
``````