Hey everyone. I recently started learning Godot 4 (two weeks to be exact) and encountered a problem with the camera turning towards the player’s movement. I study programming purely for the hobby, so I don’t really understand it, although I’m really trying to learn it. I wrote a simple script and it almost works, but the transition between the right and top sides is abrupt for obvious reasons. I have already looked through many sources, but either there is not what I need, or the explanation is too complex. I would be grateful to anyone who can help me with this problem.
func _process(_delta: float) -> void:
if Input.is_action_pressed("ui_left"):
rotation_degrees.y += 0.5
if rotation_degrees.y > 0:
rotation_degrees.y = 0
#print(rotation_degrees.y)
if Input.is_action_pressed("ui_right"):
rotation_degrees.y -= 0.5
if rotation_degrees.y < -180:
rotation_degrees.y = -180
#print(rotation_degrees.y)
if Input.is_action_pressed("ui_up"):
rotation_degrees.y -= 0.5
if rotation_degrees.y < -90:
rotation_degrees.y = -90
#print(rotation_degrees.y)
if Input.is_action_pressed("ui_down"):
rotation_degrees.y += 0.5
if rotation_degrees.y > 90:
rotation_degrees.y = 90
#print(rotation_degrees.y)