I need to clamp a variable that the user can increment with input therefore I have been clamping it in the process function. Wondering if that is a good idea or if there is anyway else I could do it.
this is what I have so far:
func _process(delta):
print(sail_angle)
if Input.is_action_pressed("sail_right"):
sail_angle += 0.1
if Input.is_action_pressed("sail_left"):
sail_angle += -0.1
sail_angle = clamp(sail_angle, -70, 70)
I mean I could also clamp it after the input action:
func _process(delta):
print(sail_angle)
if Input.is_action_pressed("sail_right"):
sail_angle += 0.1
sail_angle = clamp(sail_angle, -70, 70)
if Input.is_action_pressed("sail_left"):
sail_angle += -0.1
sail_angle = clamp(sail_angle, -70, 70)
but then I am repeating code