set_yaw NaN value

master
AiTechEye 2019-07-07 17:31:44 +02:00 committed by GitHub
parent f60ea220d9
commit 8f1f6b41f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 6 deletions

View File

@ -1600,10 +1600,7 @@ end
aliveai.walk=function(self,sp)
local pos=self.object:get_pos()
local yaw=self.object:get_yaw()
if yaw ~= yaw or type(yaw)~="number" then
return nil
end
local yaw=aliveai.nan(self.object:get_yaw())
sp=sp or 1
local x =math.sin(yaw) * -1
local z =math.cos(yaw) * 1
@ -1651,8 +1648,7 @@ aliveai.lookat=function(self,pos2,advanced,walk)
if type(pos2)=="table" then
local pos1=self.object:get_pos()
local vec = {x=pos1.x-pos2.x, y=pos1.y-pos2.y, z=pos1.z-pos2.z}
local yaw = math.atan(vec.z/vec.x)-math.pi/2
if type(yaw)~="number" then yaw=0 end
local yaw = aliveai.nan(math.atan(vec.z/vec.x)-math.pi/2)
if pos1.x >= pos2.x then yaw = yaw+math.pi end
if not advanced then self.object:set_yaw(yaw) end
self.tmp_yw=yaw