Godot Version
4.6.2
Question
How do i make a max and minium rotation cuz i want to make a plane go 60 degrees up and 60 degrees down
Help will be appreciated
Have you tried using a clamp function? It is used for exactly what you are asking for
Check out this other post. It may help.
Partial attempt based on godot docs:
var plane_up_direction = plane.transform.basis.y
var global_up_direction = Vector3(0,1,0)
# William Hamilton scribbled quaternion formula on a bridge in Ireland circa 1843.
# Clifford split it into cross-product and dot-product in 1878.
# Now in 2026 you shall dot() two vectors together to find tilt angle.
var cosine_of_angle = plane_up_direction.dot(global_up_direction)
var angle = acos(cosine_of_angle)
print ("plane is ", angle, " radians tilted from global Y")
# Remember 5 lines ago when i mentioned Quaternions? You'll have to use them.
var plane_rotation_quaternion = Quaternion(plane.transform.basis)
#plane_rotation_quaternion.set_rotation = math.clampf(plane_rotation_quaternion.get_angle(), deg_to_rad(-60), deg_to_rad(60) )
# ... and i don't know how to set exact quaternion angles.
plane.transform = Transform(Basis(plane_rotation_quaternion))
Itâs missing the part where you set the quaternionâs angle. godot does not have built-in Quaternion.set_angle() and i donât know the internals of quaternion mathâŚ