How to turn rotate to left or right rather than tilt camera in gdscript

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

So, the current it is:

var y_rotation = 0
if Input.is_action_pressed("cam_right"):
	y_rotation += deg2rad(90.0)
if Input.is_action_pressed("cam_left"):
	y_rotation += -deg2rad(90.0)
rotate_object_local(Vector3.UP, y_rotation * rotation_speed * delta)

Due to docker situation where mouse acting up big time in docker. So I am controlling the camera using keyboard only.

I noticed that my camera tilts rather than turn head to right/left.

See how my camera move rotate in y direction just fine? When it turn down, facing to the floor…the y direction move wrong way.
gif

How do you make it right? Or at least, make the Y stay in the fixed place without move it