mirror of
https://github.com/bevyengine/bevy
synced 2025-02-16 14:08:32 +00:00
Fix breakout example bug - ball flying out when collide paddle and wall at the same time (#685)
Fix breakout bug - ball flying out when collide paddle and wall
This commit is contained in:
parent
90ea5b1e6b
commit
9db8ae7a16
1 changed files with 6 additions and 2 deletions
|
@ -33,6 +33,7 @@ struct Scoreboard {
|
|||
enum Collider {
|
||||
Solid,
|
||||
Scorable,
|
||||
Paddle,
|
||||
}
|
||||
|
||||
fn setup(
|
||||
|
@ -53,7 +54,7 @@ fn setup(
|
|||
..Default::default()
|
||||
})
|
||||
.with(Paddle { speed: 500.0 })
|
||||
.with(Collider::Solid)
|
||||
.with(Collider::Paddle)
|
||||
// ball
|
||||
.spawn(SpriteComponents {
|
||||
material: materials.add(Color::rgb(1.0, 0.5, 0.5).into()),
|
||||
|
@ -240,7 +241,10 @@ fn ball_collision_system(
|
|||
*velocity.y_mut() = -velocity.y();
|
||||
}
|
||||
|
||||
break;
|
||||
// break if this collide is on a solid, otherwise continue check whether a solid is also in collision
|
||||
if let Collider::Solid = *collider {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue