pub fn approach_vec3(
current: Vec3,
target: Vec3,
max_rate: f32,
dt: f32,
) -> Result<Vec3, MotionError>Expand description
Approach a 3D target by at most max_rate * dt in Euclidean distance.
This is the 3D counterpart of approach_vec2, with identical validation,
units, no-overshoot behavior and floating-point limits. The bound applies to
the whole vector, so diagonal movement does not receive extra acceleration.
use ferravex_math::Vec3;
use ferravex_play::motion::approach_vec3;
let velocity = approach_vec3(Vec3::ZERO, Vec3::new(2., 3., 6.), 7., 0.5)?;
assert_eq!(velocity, Vec3::new(1., 1.5, 3.));