From be01dd710eaaf74562ea4479d171055af10f1e91 Mon Sep 17 00:00:00 2001 From: Eltrac Date: Thu, 13 Mar 2025 14:36:18 +0800 Subject: fix: loots blocking the way set loots as sensor to allow contact listen but avoid physical collision --- utils/bodyLifecycleManager.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'utils') diff --git a/utils/bodyLifecycleManager.lua b/utils/bodyLifecycleManager.lua index 8989a7e..3a65d7a 100644 --- a/utils/bodyLifecycleManager.lua +++ b/utils/bodyLifecycleManager.lua @@ -10,10 +10,10 @@ function bodyLifeCycleManager.new() return self end -function bodyLifeCycleManager:create(object, shape, bodyType) +function bodyLifeCycleManager:create(object, shape, bodyType, sensor) table.insert( self.toCreate, - {object = object, shape = shape, bodyType = bodyType} + {object = object, shape = shape, bodyType = bodyType, sensor = sensor == nil and false or sensor} ) end @@ -35,6 +35,9 @@ function bodyLifeCycleManager:update(dt) if self.toCreate and #self.toCreate > 0 then for _, data in ipairs(self.toCreate) do physics.bodifyObject(G.world, data.object, data.shape, data.bodyType) + if data.sensor then + data.object.fixture:setSensor(true) + end end self.toCreate = {} end -- cgit v1.2.3