Skip to content

Commit

Permalink
Fix collision detection by calculating positive penetration depth. (#966
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ak-1 authored Dec 1, 2020
1 parent ef99e59 commit 0b818d7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/bevy_sprite/src/collide_aabb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub fn collide(a_pos: Vec3, a_size: Vec2, b_pos: Vec3, b_size: Vec2) -> Option<C
// if we had an "x" and a "y" collision, pick the "primary" side using penetration depth
match (x_collision, y_collision) {
(Some(x_collision), Some(y_collision)) => {
if y_depth < x_depth {
if y_depth.abs() < x_depth.abs() {
Some(y_collision)
} else {
Some(x_collision)
Expand Down

0 comments on commit 0b818d7

Please sign in to comment.