TF2 Turret Pose Parameters

Hey guys, I am trying to make this:

Point at the player.

I am aware that you use pose parameters for this, here is my current code:

function ENT:Think()

    self:SetPoseParameter( "aim_yaw", self.Owner:GetPos().x )
    // -15 to 15
     self:SetPoseParameter( "aim_pitch", 0 )


The issue is, I am not sure how to translate the players vector pos into an angle that the turret can use properly. Any help is appreciated!

Also, while this issue has been raised, whenever I use the self:Visible(self.Owner) the setting of the pose parameter becomes extremely jagged instead of smooth, anyone know why?

You gotta use angles, not player position.

Try something like ( self:GetPos() - self.Owner:GetPos() ):Angle().y


It doesn’t point at the player. Kinda just spins around alot slower. Do you have any examples? I am sure this would have been done before.

if self:SetPoseParameter( “aim_yaw”, 0 ) does what I think it does, then this should do it.

local AimAngle = (self.Owner:GetPos()-self.Entity:GetPos()):Angle()
self:SetPoseParameter( “aim_yaw”, math.Clamp(math.NormalizeAngle(AimAngle.y), -15, 15) )

If it uses radians (it shouldn’t but might), then you should use this.
local AimAngle = (self.Owner:GetPos()-self.Entity:GetPos()):Angle()
self:SetPoseParameter( “aim_yaw”, math.rad(math.Clamp(math.NormalizeAngle(AimAngle.y), -15, 15) ) )