Not sure which direction your axis's are pointing so you'll have to adjust rotate_xyz()
accordingly a direct answer to your question would be
func _unhandled_input(event): # This function for mouse direction
if event is InputEventMouseMotion:
rotate_z(-lerp(0,spin,event.relative.x/20))#Spin=0.2
rotate_x(-lerp(0,spin,event.relative.y/20))
func _physics_process(delta):
That should work however may create another problem, so recommend locking mouse to the window
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
Set the camera to be the child of a spatial and manipulate the transforms of that instead