Improved camera zoom

This commit is contained in:
2024-02-12 11:53:16 +01:00
parent 1d37fcd9fd
commit 97d6fba237
2 changed files with 9 additions and 3 deletions

View File

@ -12,14 +12,16 @@ func _ready():
target_distance = position.z
Global.camera = self
func _unhandled_input(event):
if event.is_action_pressed("zoom_in"):
func _input(event):
if event.is_action_pressed("zoom_in", true):
target_distance -= zoom_speed
on_distance_changed()
get_viewport().set_input_as_handled()
if event.is_action_pressed("zoom_out"):
if event.is_action_pressed("zoom_out", true):
target_distance += zoom_speed
on_distance_changed()
get_viewport().set_input_as_handled()
func on_distance_changed():
target_distance = clampf(target_distance, zoom_min, zoom_max)