Skip to content
Merged
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
8 changes: 4 additions & 4 deletions crates/bevy_camera_controller/src/free_cam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use bevy_input::mouse::{
};
use bevy_input::ButtonInput;
use bevy_log::info;
use bevy_math::{EulerRot, Quat, Vec2, Vec3};
use bevy_math::{EulerRot, Quat, StableInterpolate, Vec2, Vec3};
use bevy_time::{Real, Time};
use bevy_transform::prelude::Transform;
use bevy_window::{CursorGrabMode, CursorOptions, Window};
Expand Down Expand Up @@ -119,7 +119,7 @@ impl Default for FreeCam {
walk_speed: 5.0,
run_speed: 15.0,
scroll_factor: 0.5,
friction: 0.5,
friction: 40.0,
pitch: 0.0,
yaw: 0.0,
velocity: Vec3::ZERO,
Expand Down Expand Up @@ -243,8 +243,8 @@ pub fn run_freecam_controller(
};
controller.velocity = axis_input.normalize() * max_speed;
} else {
let friction = controller.friction.clamp(0.0, 1.0);
controller.velocity *= 1.0 - friction;
let friction = controller.friction.clamp(0.0, f32::MAX);
controller.velocity.smooth_nudge(&Vec3::ZERO, friction, dt);
if controller.velocity.length_squared() < 1e-6 {
controller.velocity = Vec3::ZERO;
}
Expand Down