I have a small function which can help you to define if an entity is inside a cone view of another entity.
function CheckConeView(axis,entity,target,angle)
local z,u
if axis == "x" then z = Transform:Point(Vec3(1,0,0),entity,nil)
elseif axis == "y" then z = Transform:Point(Vec3(0,1,0),entity,nil)
elseif axis == "z" then z = Transform:Point(Vec3(0,0,1),entity,nil)
end
u = Transform:Point(target:GetPosition(true),nil,entity)
z = Transform:Point(z,nil,entity)
local targetAngle = Math:ACos(u:Dot(z)/(u:Length()*z:Length()))
if targetAngle < angle/2 then return true else return false end
end
This should be made as global function, then you can use this as below
function Script:PostRender()
if CheckConeView("z",self.yourPlayerCamera,self.target,90) and self.targetInRange == true then
--display health bar code
end
end
hope this make your idea possible