From 0b818d7b323d7a9104580351778b2943e08c2775 Mon Sep 17 00:00:00 2001 From: Andre Kuehne Date: Tue, 1 Dec 2020 09:33:52 +0100 Subject: [PATCH] Fix collision detection by calculating positive penetration depth. (#966) --- crates/bevy_sprite/src/collide_aabb.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_sprite/src/collide_aabb.rs b/crates/bevy_sprite/src/collide_aabb.rs index 489fdfd2c9..096ed84ed0 100644 --- a/crates/bevy_sprite/src/collide_aabb.rs +++ b/crates/bevy_sprite/src/collide_aabb.rs @@ -42,7 +42,7 @@ pub fn collide(a_pos: Vec3, a_size: Vec2, b_pos: Vec3, b_size: Vec2) -> Option { - if y_depth < x_depth { + if y_depth.abs() < x_depth.abs() { Some(y_collision) } else { Some(x_collision)