How should I get the muzzle position of a SWEP's viewmodel?
0 replies, posted
I've made this function:
[CODE]
function SWEP:GetMuzzlePos()
if !IsValid(self) then return nil end
if !IsValid(self.Owner) then return nil end
local ply=self.Owner
local vm = ply:GetViewModel()
local obj = vm:LookupAttachment( self.MuzzleAttachment )
local muzzlepos = vm:GetAttachment( obj )
return muzzlepos
end
[/CODE]
But the Z coordinate is way off and seems to draw a cross at the player's feet when I use debugoverlay.Cross. Any ideas? The offset does seem to work somewhat and get the correct X and Y coordinates, and I'm using the correct name in self.MuzzleAttachment.
Sorry, you need to Log In to post a reply to this thread.