Skip to content

Commit 0b818d7

Browse files
authored
Fix collision detection by calculating positive penetration depth. (#966)
1 parent ef99e59 commit 0b818d7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

crates/bevy_sprite/src/collide_aabb.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn collide(a_pos: Vec3, a_size: Vec2, b_pos: Vec3, b_size: Vec2) -> Option<C
4242
// if we had an "x" and a "y" collision, pick the "primary" side using penetration depth
4343
match (x_collision, y_collision) {
4444
(Some(x_collision), Some(y_collision)) => {
45-
if y_depth < x_depth {
45+
if y_depth.abs() < x_depth.abs() {
4646
Some(y_collision)
4747
} else {
4848
Some(x_collision)

0 commit comments

Comments
 (0)