Code:
function GetPointYawAngle(x1,y1,facing,x2,y2)
local yaw=atan2(y1-y2,x1-x2)-facing;
if yaw<0 then
yaw=yaw+360;
end;
return yaw;
end;
function GetUnitYawAngle(unitID1,unitID2)
if not (UnitExists(unitID1) and UnitExists(unitID2)) then
return
end;
local x1,y1,_,facing=PQR_UnitInfo(unitID1);
local x2,y2=PQR_UnitInfo(unitID2);
return GetPointYawAngle(x1,y1,deg(facing),x2,y2)
end;
function IsUnitFacingUnit(unitID1,unitID2)
local yawAngle=GetUnitYawAngle(unitID1,unitID2);
return yawAngle>90 and yawAngle<270
end;
function IsUnitBehindUnit(unitID1,unitID2)
return not IsUnitFacingUnit(unitID2,unitID1);
end;
Sorry for necroing, but can anyone confirm there's not any error in code? Everything works great, but i just have fps drops when i use this code ( been using this for almost half year)