check obj exists

This commit is contained in:
Alexsandro Percy 2025-02-09 08:24:03 -03:00
parent 27e140ae6d
commit e1bbf50819

View file

@ -37,6 +37,7 @@ function airutils.on_deactivate(self)
end end
function airutils.on_activate(self, staticdata, dtime_s) function airutils.on_activate(self, staticdata, dtime_s)
if not self.object then return end
local pos = self.object:get_pos() local pos = self.object:get_pos()
airutils.actfunc(self, staticdata, dtime_s) airutils.actfunc(self, staticdata, dtime_s)
self._flap = false self._flap = false
@ -136,6 +137,8 @@ function airutils.on_step(self,dtime,colinfo)
self.colinfo = colinfo self.colinfo = colinfo
self.height = airutils.get_box_height(self) self.height = airutils.get_box_height(self)
if not self.object then return end
-- physics comes first -- physics comes first
local vel = self.object:get_velocity() local vel = self.object:get_velocity()
local pos = self.object:get_pos() local pos = self.object:get_pos()
@ -165,8 +168,10 @@ function airutils.on_step(self,dtime,colinfo)
end end
end end
if self.hp_max <= 0 then if self.hp_max then
airutils.destroy(self) if self.hp_max <= 0 then
airutils.destroy(self)
end
end end
self:physics() self:physics()