# Get rotation_degrees from rotation

Attention Topic was automatically imported from the old Question2Answer platform.

Hello!

In my game the player can rotate his/her robot’s arm towards the mouse with this code in the robot’s arm sprite:

``````rotation=(get_global_mouse_position()-get_node("..").position).angle()+135
``````

But I would like get the angles to set shooting direction from it: when the arm points left, let the angle 180, when points up, let 90, etc.
How can I get these values? I tried switch with deg2rad and rad2deg from rotation, but I always get a very small or very large values.
The problem is the value of rotation_degrees doesn’t change during rotation and it is always the initial 180.
Or can I use the rotation_degrees somewhere in the above code to rotate the sprite in the direction of the mouse?

So you are adding 135 degrees to the angle() radians? You need to convert the unit from one to the other if it will make sense.

Without this, the robot arm facing the opposite direction. I rotate the arm around point at its right side, not center or left side.

Tomi | 2021-06-17 13:40

nahiyan | 2021-06-17 15:36

So you are adding 135 degrees to the angle() radians? You need to convert the unit from one to the other if it will make sense.

wyattb | 2021-06-17 13:57

The rotation variable contains the rotation angle in radians. rotation_degrees is the same value, but in degrees.

To convert from radians to degrees, you can use the `rad2deg()` function.

You can also just change rotation_degrees without touching rotation.
For example, if you want to make your player face the mouse, you can use this:

``````var angle = (get_global_mouse_position()-get_node("..").position).angle()