Garry's Mod Wiki

WEAPON:DrawWorldModel

WEAPON:DrawWorldModel( number flags )

Description

Called when we are about to draw the world model.

Arguments

1 number flags
The STUDIO_ flags for this render operation.

Example

The default action - render the world model.

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

Example

Draw the world model on the player without bonemerging it.

SWEP.WorldModel= "some_model.mdl" if CLIENT then local WorldModel = ClientsideModel(SWEP.WorldModel) -- Settings... WorldModel:SetSkin(1) WorldModel:SetNoDraw(true) function SWEP:DrawWorldModel() local _Owner = self:GetOwner() if (IsValid(_Owner)) then -- Specify a good position local offsetVec = Vector(5, -2.7, -3.4) local offsetAng = Angle(180, 90, 0) local boneid = _Owner:LookupBone("ValveBiped.Bip01_R_Hand") -- Right Hand if !boneid then return end local matrix = _Owner:GetBoneMatrix(boneid) if !matrix then return end local newPos, newAng = LocalToWorld(offsetVec, offsetAng, matrix:GetTranslation(), matrix:GetAngles()) WorldModel:SetPos(newPos) WorldModel:SetAngles(newAng) WorldModel:SetupBones() else WorldModel:SetPos(self:GetPos()) WorldModel:SetAngles(self:GetAngles()) end WorldModel:DrawModel() end end
Output:

Page Links


Special Pages


Wikis

?

Render Time: 77ms

DB GetPage 45
Generate Html 8
SaveChanges (1) 9
Render Body 0
Render Sidebar 12