changing the SWEP world model so that it fits correctly?
3 replies, posted
Is it possible to take a random prop and use it as a world model for a swep , asuming it's a 3rd person script and firstperson model doesn't matter (so no animations or anything needed)
Now I know I can just change the model path for the world model , but is there any way to actually align it correctly (it's just in the origin of the player model otherwise)
Use [url]http://www.facepunch.com/threads/1032378-SWEP-Construction-Kit-developer-tool-for-modifying-viewmodels-ironsights[/url]
[lua]
SWEP.Offset = {
Pos = {
Right = 0,
Forward = 0,
Up = 0,
},
Ang = {
Right = 0,
Forward = 0,
Up = 0,
},
Scale = Vector(),
}
function SWEP:DrawWorldModel( )
if not ValidEntity( self.Owner ) then
return self:DrawModel( )
end
local offset, hand
self.Hand2 = self.Hand2 or self.Owner:LookupAttachment( "anim_attachment_rh" )
hand = self.Owner:GetAttachment( self.Hand2 )
if not hand then
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:SetModelScale( self.Offset.Scale )
self:DrawModel( )
end[/lua]
Simply adjust the Pos and Ang to your liking until your prop fits.
Code by Kogitsune.
thank you very much , very useful code snippet.
Sorry, you need to Log In to post a reply to this thread.