SWEP not shooting from weapon point.

My friend has been working on the SWEPs for our project but he is sick so I am tweaking a current swep we have now. The weapon shoots a grenade like a m203 type grenade but it shoots from the center of the screen.

I have downloaded a bunch of other weapons to check their code, but I can’t seem to figure out how to change where the projectile comes out at. I thought it would be the SetPos but the only thing I have seen different in the SWEPs SetPos is

[lua]ent:SetPos (self.Owner:EyePos() + (self.Owner:GetAimVector() * 14));[/lua]

The multiplier at the end is the only thing I have seen changed. And every time I change that I don’t really see a noticeable change (mostly because I don’t know what it changes).

Anyone offer me some helpful advice?

14 is the distance from the player’s eye position. I have no idea about the actual issue though.

I am so sorry to inform you of this… but unless I’m wrong, and I really hope I am, that’s just how source works. I too struggled with projectile weapons, but they all seem to do the same thing - fire from your face, giving a horrendously unrealistic experience.

I tried everything, from simple adjustments to completely overhauling the way it works. I got the weirdest results.

There is hope though, in the form of an offset. It works by changing where the projectile starts but it also changes where it hits… Think of moving the eye trace down and to the right, it’s not completely accurate but I think this is what they did in EP2 with the bugbait.

You need to subtract your shootpos by, say, 25 when the player is standing, and 15 when it’s crouching.

local vec = (self:Crouching() and Vector(0,0,15)) or Vector(0,0,25)
ent:SetPos(self.Owner:EyePos() + (self.Owner:GetAimVector() * 14)-vec);

Use the player’s right hand attachment pos, mayhaps?

This snip is from the Half Life 1 Rennaissance pack by Silverlan. It shoots the grenade projecttile properly. Heres the code from the secondary attack

SWEP.NextSecondaryAttack = 0
function SWEP:SecondaryAttack()
	self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
	self.Weapon:SetNextPrimaryFire( CurTime() + self.Secondary.Delay )

	if ( !self:CanSecondaryAttack() ) then return end
	self:EmitSound( self.Secondary.Sound )
	// In singleplayer this function doesn't get called on the client, so we use a networked float
	// to send the last shoot time. In multiplayer this is predicted clientside so we don't need to 
	// send the float.
	if ( (SinglePlayer() && SERVER) || CLIENT ) then
			self.Weapon:SetNetworkedFloat( "LastShootTime", CurTime() )
	if CLIENT then return end
	local grenade_phys = ents.Create( "monster_handgrenade" )
	grenade_phys.damage = sk_wep_mp5_gren_value
	grenade_phys.owner = self.Owner
	grenade_phys.type = "wgrenade"
	grenade_phys:SetOwner( self.Owner )
	grenade_phys:SetModel( "models/items/ar2_grenade.mdl" )
	grenade_phys:SetPos( self.Owner:GetShootPos() )

	local FireTrace = self:GetPos() +Vector( 30, 0, 0 )
	local Firevector = FireTrace:GetNormalized()
	local FireLength = FireTrace:Length()
	local ArriveTime = FireLength / 2000
	local BaseShootVector = Firevector * 600 + Vector(0,0,300 * ArriveTime)

	local phys = grenade_phys:GetPhysicsObject()
	if phys:IsValid() then
		local pl_eye_ang = self.Owner:EyeAngles()
		local grenade_phys_throwpos = self.Owner:GetShootPos() + pl_eye_ang:Right() * 5 - pl_eye_ang:Up() * 7
		local grenade_phys_throwpos_f = ( util.TraceLine( util.GetPlayerTrace( self.Owner ) ).HitPos - grenade_phys_throwpos ):GetNormalized()
		phys:SetVelocity( grenade_phys_throwpos_f * 800 )
	// Remove 1 bullet from our clip
	self:TakeSecondaryAmmo( 1 )
	self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK ) 		// View model animation
	self.Owner:SetAnimation( PLAYER_ATTACK1 )				// 3rd Person Animation
	if ( self.Owner:IsNPC() ) then return end
	// Punch the player's view
	self.Owner:ViewPunch( Angle( math.Rand(-0.2,-0.1) * self.Secondary.Recoil, math.Rand(-0.1,0.1) *self.Secondary.Recoil, 0 ) )

Good luck :stuck_out_tongue: