Hey guys, I am trying to make this:
[URL=http://s1187.photobucket.com/user/Fortune11709/media/thatturret_zps8701b238.jpg.html][IMG]http://i1187.photobucket.com/albums/z394/Fortune11709/thatturret_zps8701b238.jpg[/IMG][/URL]
Point at the player.
I am aware that you use pose parameters for this, here is my current code:
[CODE]function ENT:Think()
self:SetPoseParameter( "aim_yaw", self.Owner:GetPos().x )
// -15 to 15
self:SetPoseParameter( "aim_pitch", 0 )
end[/CODE]
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
-snip-
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.
[lua]
local AimAngle = (self.Owner:GetPos()-self.Entity:GetPos()):Angle()
self:SetPoseParameter( "aim_yaw", math.Clamp(math.NormalizeAngle(AimAngle.y), -15, 15) )
[/lua]
If it uses radians (it shouldn't but might), then you should use this.
[lua]
local AimAngle = (self.Owner:GetPos()-self.Entity:GetPos()):Angle()
self:SetPoseParameter( "aim_yaw", math.rad(math.Clamp(math.NormalizeAngle(AimAngle.y), -15, 15) ) )
[/lua]
Sorry, you need to Log In to post a reply to this thread.