How to manipulate weapon position

I want to manipulate the position of the world model of a swep. I assume it would be relative to the person object holding it.

Is there a way to do this? I know how to manipulate bones of the player, but the gun just floats in front of them :confused:

I would prefer to set the position in server code instead of the swep file.

(Any other way than just spawning a gun and getting the position of the ply and just making it relative to that?

Set the render position in this hook:

SWEP:DrawWorldModel

I was just going to get the activeweapon and set it by position relative to the person that way.

For whatever reason, I can’t seem to make anything a world model besides a slam or a pistol. :confused:

Correction, I can’t make anything a world model :confused:




SWEP.PrintName			= "Restrainer"
SWEP.Author				= "McRibby"

SWEP.Spawnable = true
SWEP.AdminOnly = true

SWEP.Primary.ClipSize		= -1
SWEP.Primary.DefaultClip	= -1
SWEP.Primary.Automatic		= false
SWEP.Primary.Ammo			= "none"

SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic	= false
SWEP.Secondary.Ammo			= "none"

SWEP.Weight				= 5
SWEP.AutoSwitchTo		= false
SWEP.AutoSwitchFrom		= false

SWEP.Slot				= 1
SWEP.SlotPos			= 2
SWEP.DrawAmmo			= false
SWEP.DrawCrosshair		= false

SWEP.ViewModel			= "models/weapons/v_pistol.mdl"
SWEP.WorldModel			= "models/weapons/w_slam.mdl"

function SWEP:Initialize()

	self:SetHoldType("passive")
	JSply = self:GetOwner()

end

function SWEP:Deploy()
	self.Owner:DrawViewModel(false)
end



That code doesn’t have the hook I linked.

Yea, I tried it with that hook, still nada.




SWEP.PrintName			= "Restrainer"
SWEP.Author				= "McRibby"

SWEP.Spawnable = true
SWEP.AdminOnly = true

SWEP.Primary.ClipSize		= -1
SWEP.Primary.DefaultClip	= -1
SWEP.Primary.Automatic		= false
SWEP.Primary.Ammo			= "none"

SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic	= false
SWEP.Secondary.Ammo			= "none"

SWEP.Weight				= 5
SWEP.AutoSwitchTo		= false
SWEP.AutoSwitchFrom		= false

SWEP.Slot				= 1
SWEP.SlotPos			= 2
SWEP.DrawAmmo			= false
SWEP.DrawCrosshair		= false

SWEP.ViewModel			= "models/weapons/v_pistol.mdl"
SWEP.WorldModel			= "models/weapons/w_slam.mdl"

function SWEP:Initialize()

	self:SetHoldType("passive")

end

function SWEP:DrawWorldModel()
	self:DrawModel()
end

function SWEP:Deploy()
	self.Owner:DrawViewModel(false)
end




Still doesn’t work :confused:

What exactly “isn’t working?” You won’t be able to see it unless you go third-person since you disabled the viewmodel.

Well I have another player in the game in which I give the weapon. What doesn’t work is the world model. It doesn’t show up. Mind you another player has the weapon equipped (not a bot).

It’s probably inside of his player model since you’re using the SLAM wm that doesn’t have any attachments.

Nope, already checked that. It’s empty.

Welp, guess I’ll never find out my problem :confused:

I tested your code and the SLAM shows up fine:

It’s just a bit hard to see because of your hold type.

Already fixed my problemo

http://forum.facepunch.com/showthread.php?t=1574876

Well I have messed around enough to find out that the world model counts as the actual weapon model itself which probably means you can set the position of all of them if they are equipped to somewhere else. Parenting them to the players hand might work too.