camera: added camera zooming

This commit is contained in:
Simon Ward 2026-01-25 19:10:13 +13:00
parent 7fb2d4b1f9
commit 35e193d74f
4 changed files with 21 additions and 1 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 = 0
var zoom_max = 100
var current_zoom = 0
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_in"):
current_zoom += 5
elif event.is_action_pressed("zoom_out"):
current_zoom -= 5
func _process(delta):
# rotate outer gimbal around y axis
@ -57,3 +64,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)