Improved camera zoom
This commit is contained in:
parent
1d37fcd9fd
commit
97d6fba237
@ -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)
|
||||
|
@ -119,11 +119,15 @@ toggle_fullscreen={
|
||||
zoom_in={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":4,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":true,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194437,"key_label":0,"unicode":43,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
zoom_out={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":5,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":true,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194435,"key_label":0,"unicode":45,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user