• Making an entity 'track' a player
    0 replies, posted
So I'm attempting to have an entity face/track a player as he/she moves using the following code (This code isn't exactly what I'm using. I've changed small bits to help readability) [code] local AngDifference =Angle((self:GetPos().y - CurrentTarget:GetPos().y) - self:GetAngles().y) -- Turn Left if AngDifference > 181 and AngDifference < 360 then self:SetAngles(Angle(self:GetAngles().p, self:GetAngles().y + 1, self:GetAngles().r)) -- Turn Right elseif AngDifference < 179 and AngDifference > 0 then self:SetAngles(Angle(self:GetAngles().p, self:GetAngles().y - 1, self:GetAngles().r)) end[/code] Now I'm sure that I'm missing some basic principal of this type of thing. But this tracks just fine, until I pass a specific spot on the Y axis. At which point, depending on the direction I pass through, AngDifference will return 500+ or 30 or less(rough numbers). Anybody have some input? Maybe a better way to achieve this or somewhere to look for information. Any help would be appreciated and if any more information is needed I can provide it.
Sorry, you need to Log In to post a reply to this thread.