Need help with self.Owner:GetShootPos()

Hi, I am trying to make a effect that originates from where the muzzle of the swep should be.
But when I do
effectdata:SetOrigin( self.Owner:GetShootPos())
The effect always comes out of the players head.


I usually just get the players position then add some mulitple of the forward, right, and up vectors to get it the the right position. Something like this. local startPos = self.Owner:GetPos() + self.Owner:Forward()*x+ self.Owner:Right()*y+self.Owner:Up()*z) Just mess with the x, y, and z until it is in the correct position.

Wouldn’t it be different for every gun?

I’ve recently been trying to find an easy way to find it, because getting the muzzle attachment doesn’t work most models.

This really pisses me off- I’m actually trying to find an alternative to the muzzle attachment as we speak.

Also, have you tried the Right or Left Hand attachment for the player? It’s not perfect but it’s a little closer to the muzzle.

Not all my models have it, I’m actually using GetBonePosition to get the position of the hands. I’m making custom AI and I had to attach weapons to them, and not all of my models have the right hand attachment. I’ll try using it on the players.

I’m not too familiar with bone positions or how effects are done on a weapon, but the game knows how to properly place a muzzle flash, so can’t you look into that code and see what they do?

Because we can all read compiled code. Unless that’s somewhere in the public SDK, you’ve got no chance.

…none of you helped, let’s say I am useing the gravgun model, how do I make it so the effect originates from the orange glow is?

Guess and check. Start off with the right hand attachment (because it generally moves the least) then manually position the effect.

function getGunPosAng(GUN)
local attachmentID=GUN:LookupAttachment(“anim_attachment_RH”);
return GUN:GetAttachment(attachmentID)

– when making the effect…
local effectdata = EffectData()
effectdata:SetOrigin(getGunPosAng(self.Owner).Pos + self.Owner:GetForward()*7 + self.Owner:GetUp() * 3)

– the self.Owner:GetForward()*7 and self.Owner:GetUp() * 3 are manually repositioning the effect with respect to the players right hand.