ENTITY:Draw

From Garry's Mod
Jump to: navigation, search
 ENTITY:Draw( )

Contents

Description

Called if and when the entity should be drawn opaquely, based on the Entity:GetRenderGroup of the entity.

See ENT structure and RENDERGROUP_ Enums for more information.

Arguments

number flags

The bit flags from STUDIO_ Enums

Examples

Example

Draws the model And makes a rotating text over the entity

function ENT:Draw()
        //Drawing the model
	self:DrawModel()
	
        //The amount to display
	local amount = 10
	
	local Pos = self:GetPos()
	local Ang1 = Angle(0, 0, 90)
	local Ang2 = Angle(0, 0, 90)
	
	Ang1:RotateAroundAxis(Ang1:Right(), self.rotate)
	Ang2:RotateAroundAxis(Ang2:Right(), self.rotate + 180)

	//Draws front
	cam.Start3D2D(Pos + Ang1:Up() * 0, Ang1, 0.2)
		draw.DrawText("$ "..amount, "Default", 0, -50, Color(0, 255, 0, 255),TEXT_ALIGN_CENTER)
	cam.End3D2D()
	
	//Draws back
	cam.Start3D2D(Pos + Ang2:Up() * 0, Ang2, 0.2)
		draw.DrawText("$ "..amount, "Default", 0, -50, Color(0, 255, 0, 255),TEXT_ALIGN_CENTER)
	cam.End3D2D()
	
	//Resets the rotation
	if(self.rotate > 359) then self.rotate = 0 end
	
	//Rotates
	self.rotate = self.rotate - (100*(self.lasttime-SysTime( )))
	self.lasttime = SysTime()
end


Personal tools
Navigation