Improved camera zoom
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user