Hey guys,
I'm having a problem with a custom model I made, the view model is just fine but the world model is way too far from the right hand.
I wanted to change the Pos of the world model to get closer to players hand. What's the function that works with the World Model pos? (I want to edit this from the SWEP lua file)
Thanks in Advance
You want to use this
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/WEAPON/DrawWorldModel]SWEP:DrawWorldModel[/url]
Inside that function you can use some things like
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetRenderOrigin]Entity:SetRenderOrigin[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetRenderAngles]Entity:SetRenderAngles[/url]
Tried this:
[LUA]
// World View Vector/Angle
local Ppos = Vector(0, -0.460, 0.00849151)
local Pang = Angle(180, 180, 0)
// Draw World Model
function SWEP:DrawWorldModel()
if CLIENT then
local ply = LocalPlayer()
local boneid = ply:LookupBone( "ValveBiped.Bip01_R_Hand" )
if not boneid then
return
end
local matrix = ply:GetBoneMatrix( boneid )
if not matrix then
return
end
local newpos, newang = LocalToWorld( Ppos, Pang, matrix:GetTranslation(), matrix:GetAngles() )
self:SetRenderOrigin(newpos)
self:SetRenderAngles(newang)
self:DrawModel()
end
end
[/LUA]
I know the vector and angle are right because I used Pac3 to get them, and I used "right hand" (aka ValveBiped.Bip01_R_Hand) as the bone.
But now I don't even see the model at all, any ideas? Maybe I missed something in my code?
Thanks
Sorry, you need to Log In to post a reply to this thread.