+1 vote

I have a couple of questions about angles and the property rotation in Godot.

-Why is the property rotation of a node2D measured in radians while rect_rotation on a Control node is measured in degrees?.

I know you can transform from radians to degrees but it took me a while to check the documentation for rect_rotation to realise I was using the wrong measurement. So I was wondering if there is a reason. Do degrees work better on Control nodes and that's why it's their default?.

-My second question is about angles and this may be more of a math problem more than an engine thing.

When I add degrees to the rotation_degree property of a Node2D the rotation property goes over and under 360 and -360 is there a use for this?

Personally I don't understand why would you use negative degrees a part from the obvious clockwise rotation from subtracting degrees. But once you hit 0 you can make the rotation 360 and achieve the same result right?.

I'm achieving this by manually resetting the rotation, let me know if there's a better way of doing this:

if rotation_degrees >= 360 or rotation_degrees <= 0: 
rotation_degrees = fposmod(rotation_degrees,360.0)

So why does the engine not do that automatically is there a reason to save the rotation of an object as 1000 degrees? or -1000 degrees?

in Engine by (397 points)
edited by

2 Answers

+1 vote

There is a lerp_angle() function.

Although this is not 100% what You asked, it could solve it.
Plus, this might is what Someone else is looking for (like Me before)

by (24 points)
0 votes

about the different angle units (degrees and radians):
where radians are needed, you can use deg2rad(yourdegreesangle) and calculate your degrees angle inside it´s brackets
deg2rad(90.0 / 60.0)
can be used to rotate 90° in 60 steps

by (74 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.