-
Is there a way to constrain the maximum speed of an object so that when acceleration is applied the velocity is clipped to that value? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
At the moment, there is no built-in way to do that. What you can do is make sure to clamp the velocity at each update: #[derive(Component)]
struct MaxSpeed(f32);
fn enforce_max_velocity(mut bodies: Query<&mut Velocity, &MaxSpeed>) {
for (mut velocity, MaxSpeed(max_speed)) in bodies.iter_mut() {
velocity.linear = velocity.linear.clamp_length_max(max_speed);
}
} Of course, we could add a |
Beta Was this translation helpful? Give feedback.
At the moment, there is no built-in way to do that.
What you can do is make sure to clamp the velocity at each update:
Of course, we could add a
MaxSpeed
component in heron.