Been trying to create a basic orbit camera. So far I've managed to get the mouse motion event to turn a camera Gimbal node. Works fine for Horizontal rotations.
However, I can't seem to figure out how I can limit the Vertical Rotations. Ideally I want to limit the rotations between 1 and 89, as not to rotate over the top of the orbit pivot point.
extends Spatial
func _ready():
set_process_input(true)
func _input(ev):
if (ev.is_class("InputEventMouseMotion")):
if (ev.button_mask&(BUTTON_MASK_LEFT)):
var speed = ev.get_relative()
rotate_y(clamp(speed.x,-0.1,0.1))
get_node("InnerGimbal").rotate_x(clamp(speed.y,-0.1,0.1))
So I've tried clamping the rotation of the InnerGimbal, however when rotate_x is called it just ignores the clamp. So I'm not sure what to do.