diff --git a/scenes/player.gd b/scenes/player.gd index 5223894..6ca9d0a 100644 --- a/scenes/player.gd +++ b/scenes/player.gd @@ -7,6 +7,9 @@ const MOVE_SPEED := 8.0 const ACCELLERATION := 30.0 const DECELLERATION := 40.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 rotation_x := 0.0 var rotation_y := 0.0 @@ -75,3 +78,14 @@ func _input(event): $Camera3D.rotation.x = rotation_x 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) +