Fix crash nan.

master
_Zaizen_ 2020-08-07 22:53:55 +02:00
parent 09b563a0aa
commit 89a7b417ae
1 changed files with 6 additions and 3 deletions

View File

@ -192,7 +192,9 @@ function grenade_set_entity(name, def)
local yaw = minetest.dir_to_yaw(direction)
local speed = vector.length(velocity)
local pitch = math.acos(velocity.y/speed) - math.pi/3
obj:set_rotation({x = 0, y = yaw + math.pi/2, z = pitch})
if tostring(pitch) ~= 'nan' then
obj:set_rotation({x = 0, y = yaw + math.pi/2, z = pitch})
end
--print(drag)
local acceleration = vector.multiply(velocity, -drag)
--local acceleration = vector.multiply(direction, -drag)
@ -214,8 +216,9 @@ function grenade_set_entity(name, def)
print(-direction.z * 13 * (self.sliding + 1))
print("ZZZZZZZZZZZZZZZZZZZZZZZZZZZZ")
]]
obj:set_acceleration(acceleration)
if tostring(acceleration) ~= 'nan' then
obj:set_acceleration(acceleration)
end
--[[
obj:set_acceleration({
x = -direction.x * (self.initial_properties.throw_speed/2) * self.sliding,