Add camera zoom

This commit is contained in:
Lucas 2025-11-07 17:11:59 -06:00
parent 0e03ced3c6
commit e013ef7875

View File

@ -7,6 +7,9 @@ const MOVE_SPEED := 8.0
const ACCELLERATION := 30.0 const ACCELLERATION := 30.0
const DECELLERATION := 40.0 const DECELLERATION := 40.0
const JUMP_SPEED := 4.0 const JUMP_SPEED := 4.0
const MIN_FOV := 10
const MAX_FOV := 180
const ZOOM_FACTOR := 1.1 # Zoom out when >1, in when < 1
var mouse_sensitivity := 0.005 var mouse_sensitivity := 0.005
var rotation_x := 0.0 var rotation_x := 0.0
var rotation_y := 0.0 var rotation_y := 0.0
@ -75,3 +78,14 @@ func _input(event):
$Camera3D.rotation.x = rotation_x $Camera3D.rotation.x = rotation_x
rotation.y = rotation_y rotation.y = rotation_y
if event is InputEventMouseButton and event.pressed:
if event.button_index == MOUSE_BUTTON_WHEEL_UP:
zoom_camera(1.0 / ZOOM_FACTOR) # Zoom in
elif event.button_index == MOUSE_BUTTON_WHEEL_DOWN:
zoom_camera(ZOOM_FACTOR) # Zoom out
func zoom_camera(factor):
var new_fov = cam.fov * factor
cam.fov = clamp(new_fov, MIN_FOV, MAX_FOV)