mirror of
https://github.com/APercy/airutils.git
synced 2025-03-15 08:01:22 +00:00
improved vehicle destruction code
This commit is contained in:
parent
758ce12162
commit
59f4865a07
3 changed files with 8 additions and 0 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue