# How do I convert degrees to radians and vice versa in Godot?

In a game I'm toying with in Godot engine I have angles given in degrees in some places and angles given in radians in other places. Sometimes I need to mix both angles (ie. add them).

What built-in function allows me to convert degrees to radians (and the other way around)? Or is there none?

P.S. I realize that converting those is not rocket science and I could code something on my own, but Godot is already doing such conversions internally, so I would venture a guess that such function already exists.

• I'm down-voting this question for not showing research effort. Even not knowing Godot, I was able to find the engine documentation, enter a search for the word "degrees," and find the methods Tyyppi_77 links below in seconds. Please take the time to do at least this level of investigation when faced with a game development problem. Sep 16, 2017 at 12:05
• @DMGregory I guess I couldn't find those, because I was searching for "radians" in the documentation.
– jahu
Sep 16, 2017 at 12:08
• Here are the search results for radians, which also include the hit that Tyyppi_77 links. Sep 16, 2017 at 12:11
• @DMGregory Then I guess I missed it (happens). P.S. I think our two comments in the middle can be deleted now.
– jahu
Sep 16, 2017 at 12:13
• I'm voting to close this question as off-topic because it's asking if "product X offers feature Y". Sep 16, 2017 at 13:31

This can be achieved:

Each function takes a float (the value being converted) and returns a float (the converted value).

Some nodes in Godot 3.0 have a property rotation_degrees that you can use, i.e

# rotate the node a quarter turn using radians
my_2D_node.rotation += PI / 2
# read the current rotation in degrees
my_2D_node.rotation_degrees


The property rotation_degrees can be read and set, so you can for example write the property as .rotation in radians where convenient and somewhere else in the script read the property as .rotation_degrees if degrees would be more convenient. The object will do the conversion for you

• This is a comment, not an answer Nov 7, 2018 at 6:45
• You're not answering the question. The OP is asking the way to convert degree to radians and vice versa. Nov 7, 2018 at 10:13
• Arguably, this could be an answer in some contexts. If the reason you wanted to convert between degrees & radians was that all your math was in degrees, but the nodes only had a rotation_radians property, then learning about a rotation_degrees property could solve the problem by letting you skip the conversion entirely. I would recommend editing this answer to explain how to use this property to solve the problem, or converting it to a comment as suggested above. Nov 7, 2018 at 13:08
• I also thought this was an answer as I had the same question as the OP and found this to be my solution. I'll clarify how it could be used Nov 12, 2018 at 16:07