summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-03-13 14:36:18 +0800
committerEltrac <hi@guhub.cn>2025-03-13 14:36:18 +0800
commitbe01dd710eaaf74562ea4479d171055af10f1e91 (patch)
tree935a49a1debae8497d0e04574af61b2a35fa0d61 /utils
parentd0c372b1e5d195c0eeeffe05f16930c53adb6818 (diff)
fix: loots blocking the way
set loots as sensor to allow contact listen but avoid physical collision
Diffstat (limited to 'utils')
-rw-r--r--utils/bodyLifecycleManager.lua7
1 files changed, 5 insertions, 2 deletions
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