From 0910dc3f66fe377df51724c6559fa168ce6c5a8f Mon Sep 17 00:00:00 2001 From: Eltrac Date: Wed, 12 Mar 2025 17:25:05 +0800 Subject: fix: occasional error when one of the contacted body is nil --- main.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'main.lua') diff --git a/main.lua b/main.lua index 1ea259f..a602cac 100644 --- a/main.lua +++ b/main.lua @@ -60,10 +60,12 @@ end function onContact(a, b, contact) local objectA = utils.whoseBody(a:getBody()) local objectB = utils.whoseBody(b:getBody()) - if objectA and objectA.onContact then - objectA:onContact(objectB, contact) - end - if objectB and objectB.onContact then - objectB:onContact(objectA, contact) + if objectA and objectB then + if objectA.onContact then + objectA:onContact(objectB, contact) + end + if objectB.onContact then + objectB:onContact(objectA, contact) + end end end -- cgit v1.2.3