Hey, I've been trying to solve an issue I have with a weapon model that I used for TTT, it has a working view model but the world model is borked, attaching itself to the spine of the playermodel.
I managed to find a few lines of code where you could change the weapon offset without having to edit the actual model, but then another problem sparks, whenever you drop the weapon, the entity still drops like normal, but the model itself freezes mid-air.
Here's the specific line of code for the change of the weapon position.
[lua]SWEP.Offset = {
Pos = {
Up = 0,
Right = -4,
Forward = 2,
},
Ang = {
Up = -70,
Right = -100,
Forward = 140,
}
}
function SWEP:DrawWorldModel( )
local hand, offset, rotate
if not IsValid( self.Owner ) then
self:DrawModel( )
self:Activate( )
return
end
if not self.Hand then
self.Hand = self.Owner:LookupAttachment( "anim_attachment_rh" )
end
hand = self.Owner:GetAttachment( self.Hand )
if not hand then
self:DrawModel( )
return
end
offset = hand.Ang:Right( ) * self.Offset.Pos.Right + hand.Ang:Forward( ) * self.Offset.Pos.Forward + hand.Ang:Up( ) * self.Offset.Pos.Up
hand.Ang:RotateAroundAxis( hand.Ang:Right( ), self.Offset.Ang.Right )
hand.Ang:RotateAroundAxis( hand.Ang:Forward( ), self.Offset.Ang.Forward )
hand.Ang:RotateAroundAxis( hand.Ang:Up( ), self.Offset.Ang.Up )
self:SetRenderOrigin( hand.Pos + offset )
self:SetRenderAngles( hand.Ang )
self:DrawModel( )
end[/lua]
Adding the 'self:Activate()' part seemed to have fixed the issue for the person carrying the weapon, but it still bugs out for everbody else, or if you go into thirdperson.
I have no experience with Lua and all I've done is borrowed code from here and there, hoping that it won't completely break.
Someone helped me out, turns out all you need to do was change the 'self:Activate()' to
[lua]self:SetRenderOrigin(nil)
self:SetRenderAngles(nil)
self:DrawModel( )[/lua]
Whelp.
Sorry, you need to Log In to post a reply to this thread.