Skip to main content

smooth_damp

Function smooth_damp 

pub fn smooth_damp(
    current: f32,
    target: f32,
    velocity: &mut f32,
    smooth_time: f32,
    max_speed: f32,
    delta_time: f32,
) -> f32
Expand description

Smoothly damp a scalar value toward a target.

  • current: Current value.
  • target: Target value.
  • velocity: Current velocity (mutated in place).
  • smooth_time: Approximate time to reach the target (seconds).
  • max_speed: Maximum speed.
  • delta_time: Frame time (seconds).

Returns the new value and updates velocity.