improved vehicle destruction code

This commit is contained in:
Alexsandro Percy 2023-08-24 20:14:00 -03:00
parent 758ce12162
commit 59f4865a07
3 changed files with 8 additions and 0 deletions

View File

@ -7,6 +7,7 @@ function airutils.physics(self)
local surface = nil
local surfnodename = nil
local spos = airutils.get_stand_pos(self)
if not spos then return end
spos.y = spos.y+0.01
-- get surface height
local snodepos = airutils.get_node_pos(spos)

View File

@ -119,6 +119,10 @@ function airutils.on_step(self,dtime,colinfo)
end
end
if self.hp_max <= 0 then
airutils.destroy(self)
end
self:physics()
if self.logic then
@ -214,6 +218,7 @@ function airutils.logic(self)
end
end
if not self.object:get_acceleration() then return end
local accel_y = self.object:get_acceleration().y
local rotation = self.object:get_rotation()
local yaw = rotation.y

View File

@ -42,9 +42,11 @@ function airutils.get_stand_pos(thing) -- thing can be luaentity or objectref.
local colbox = {}
if type(thing) == 'table' then
pos = thing.object:get_pos()
if not thing.object:get_properties() then return false end
colbox = thing.object:get_properties().collisionbox
elseif type(thing) == 'userdata' then
pos = thing:get_pos()
if not thing:get_properties() then return false end
colbox = thing:get_properties().collisionbox
else
return false