From f1fc0866122aad52886ec535b0e14777d0063084 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sat, 13 Jul 2024 14:19:47 +0300 Subject: [PATCH] Fix CharacterController to not process hits against removed actors --- Source/Engine/Physics/PhysX/PhysicsBackendPhysX.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/Engine/Physics/PhysX/PhysicsBackendPhysX.cpp b/Source/Engine/Physics/PhysX/PhysicsBackendPhysX.cpp index 80d264857..1047618b2 100644 --- a/Source/Engine/Physics/PhysX/PhysicsBackendPhysX.cpp +++ b/Source/Engine/Physics/PhysX/PhysicsBackendPhysX.cpp @@ -321,7 +321,12 @@ class CharacterControllerHitReportPhysX : public PxUserControllerHitReport { void onHit(const PxControllerHit& hit, Collision& c) { - ASSERT_LOW_LAYER(c.ThisActor && c.OtherActor); + if (c.ThisActor == nullptr || c.OtherActor == nullptr) + { + // One of the actors was deleted (eg. via RigidBody destroyed by gameplay) then skip processing this collision + return; + } + c.Impulse = Vector3::Zero; c.ThisVelocity = P2C(hit.dir) * hit.length; c.OtherVelocity = Vector3::Zero;