Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions crates/bevy_camera_controller/src/free_cam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,17 @@ pub fn run_freecam_controller(
return;
}

let mut scroll = 0.0;

let amount = match accumulated_mouse_scroll.unit {
MouseScrollUnit::Line => accumulated_mouse_scroll.delta.y,
MouseScrollUnit::Pixel => {
accumulated_mouse_scroll.delta.y / MouseScrollUnit::SCROLL_UNIT_CONVERSION_FACTOR
}
};
scroll += amount;
controller.walk_speed += scroll * controller.scroll_factor * controller.walk_speed;

if amount != 0.0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this if is kind of redundant, but that's a nitpick.

let factor = bevy_math::ops::exp(controller.scroll_factor * amount);
controller.walk_speed = (controller.walk_speed * factor).clamp(0.0, f32::MAX);
}
controller.run_speed = controller.walk_speed * 3.0;

// Handle key input
Expand Down