How does godots rotation system work in Spatial?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Genesis689

In the docs I have read that some method calls use radian arguments and some use degrees. Is there a way to convert one to the other? And how would I go about rotating an object?

:bust_in_silhouette: Reply From: Wakatta

#Conversions

The following are in GDScript globalscope and can be called from anywhere

##Godot 3.x

rad2deg() # radians to degrees
deg2rad() # degrees to radians

##Godot 4.x

rad_to_deg() # radians to degrees
deg_to_rad() # degrees to radians

##Rotating a Spatial

# Rotate 45 degrees on the x axis
set_rotation_degrees(Vector3(45, 0, 0))

rotate(Vector3.RIGHT, deg2rad(45))

rotate_x(deg2rad(45))

Thank you. This is quite helpful.

Genesis689 | 2022-12-27 10:45