diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-04-28 18:47:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-28 18:47:22 +0200 |
commit | 212989d467b2ab091fe0d78b4ca09e76f9c92e0d (patch) | |
tree | 2d3d0b11f10465f33f663082ad619e2e0bb292be /scene/2d | |
parent | 5a4e478b0f2f99638b5cae58c1530f152e79e22a (diff) | |
parent | e2812fcb0ff60d6484e4cc25bbb2765655cff42b (diff) |
Merge pull request #59438 from fabriceci/fix-move-and-collide-reported-collisions
Fix wrong collision reported on move_and_collide
Diffstat (limited to 'scene/2d')
-rw-r--r-- | scene/2d/physics_body_2d.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index c0f2b6f07e..749754e6c5 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -58,7 +58,11 @@ Ref<KinematicCollision2D> PhysicsBody2D::_move(const Vector2 &p_distance, bool p PhysicsServer2D::MotionParameters parameters(get_global_transform(), p_distance, p_margin); PhysicsServer2D::MotionResult result; - if (move_and_collide(parameters, result, p_test_only)) { + + bool collided = move_and_collide(parameters, result, p_test_only); + + // Don't report collision when the whole motion is done. + if (collided && result.collision_safe_fraction < 1) { // Create a new instance when the cached reference is invalid or still in use in script. if (motion_cache.is_null() || motion_cache->reference_get_count() > 1) { motion_cache.instantiate(); |