camera: added camera zooming

This commit is contained in:
Simon Ward 2026-01-25 19:10:13 +13:00 committed by Jeremy Baxter
parent c78368c89e
commit cf14e5d398
2 changed files with 20 additions and 0 deletions

View file

@ -7,6 +7,9 @@ var locked_mouse_positon = Vector2(0,0)
var mouse_locked = false
var mouse_x_velocity = 0
var mouse_y_velocity = 0
var zoom_min = 4
var zoom_max = 100
var current_zoom = 8
func reset():
basis = Basis()
@ -23,6 +26,10 @@ func _input(event):
if event is InputEventMouseMotion:
mouse_x_velocity = event.relative.x
mouse_y_velocity = event.relative.y
elif event.is_action_pressed("zoom_out"):
current_zoom += 5
elif event.is_action_pressed("zoom_in"):
current_zoom -= 5
func _process(delta):
# rotate outer gimbal around y axis
@ -56,3 +63,6 @@ func _process(delta):
# reset gimbals
if Input.is_action_pressed("cam_reset"):
reset()
current_zoom = clamp(current_zoom, zoom_min, zoom_max)
$InnerGimbal/Camera3D.position = Vector3($InnerGimbal/Camera3D.position.x, current_zoom, current_zoom)