Open
Description
I am playing with a ball like this
commands
.spawn(ShapeBundle {
path: GeometryBuilder::build_as(&shape),
transform: Transform::from_translation(Vec3::new(0., 200., 10.)),
..default()
})
.insert(Fill::color(Color::CYAN))
.insert(RigidBody::KinematicPositionBased)
.insert(Collider::ball(radius))
.insert(Restitution::coefficient(0.7))
.insert(Velocity::zero())
.insert(ColliderMassProperties::Density(1.))
.insert(Sleeping{
linear_threshold: -1.,
angular_threshold: -1.,
sleeping: false,
})
.insert(ExternalImpulse {
..default()
})
.insert(Damping { linear_damping: 0.3, angular_damping: 1.0 })
.insert(Player{
being_dragged: false,
max_distance_this_launch: 0.,
max_height_this_launch: 0.,
});
Then when user mouse release
else if mouse_button.just_released(MouseButton::Left){
//(&mut Player, &mut RigidBody, &Transform, &Collider, &mut ExternalImpulse)
if player_tuple.0.being_dragged {
player_tuple.0.being_dragged = false;
player_tuple.0.max_distance_this_launch = 0.;
player_tuple.0.max_height_this_launch = 0.;
player_tuple.4.impulse = Vec2::new(100.0, 200.0);
*player_tuple.1 = RigidBody::Dynamic;
next_state.set(AppState::Forwarding);
}
}
Then there are two cases:
- I release the ball near another collider : everything is as expected
- I release the ball far from another collider : the ball get stuck in the air with RigidBody::Dynamic and non null Velocity
Did I miss something ?