diff --git a/crates/bevy_camera_controller/src/free_cam.rs b/crates/bevy_camera_controller/src/free_cam.rs index 998d17bc66566..6c0a46e75756a 100644 --- a/crates/bevy_camera_controller/src/free_cam.rs +++ b/crates/bevy_camera_controller/src/free_cam.rs @@ -23,6 +23,7 @@ use bevy_input::mouse::{ }; use bevy_input::ButtonInput; use bevy_log::info; +use bevy_math::ops::powf; use bevy_math::{EulerRot, Quat, Vec2, Vec3}; use bevy_time::{Real, Time}; use bevy_transform::prelude::Transform; @@ -193,7 +194,9 @@ pub fn run_freecam_controller( MouseScrollUnit::Pixel => accumulated_mouse_scroll.delta.y / 16.0, }; scroll += amount; - controller.walk_speed += scroll * controller.scroll_factor * controller.walk_speed; + // By using exponentiation we ensure that this scales up and down smoothly + // regardless of the amount of scrolling processed per frame + controller.walk_speed *= powf(1.0 + controller.scroll_factor, scroll); controller.run_speed = controller.walk_speed * 3.0; // Handle key input