ENTITY/RenderOverride

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Better wording)
(Added usage example)
Line 7: Line 7:
 
|Name=RenderOverride
 
|Name=RenderOverride
 
|Parent=ENTITY
 
|Parent=ENTITY
 +
}}
 +
{{Example
 +
|Description=Don't draw the entity we've picked if we're its owner.
 +
|Code=local function DontDrawMe( self )
 +
if self:GetOwner() == LocalPlayer() then
 +
return
 +
end
 +
 +
self:DrawModel()
 +
end
 +
 +
local pickent = Entity(1):GetEyeTrace().Entity
 +
 +
if ( IsValid( pickent ) ) then
 +
pickent.RenderOverride = DontDrawMe
 +
end
 
}}
 
}}

Revision as of 16:05, 7 May 2015

 ENTITY:RenderOverride( )

Description

Called instead of the engine drawing function of the entity.

This hook works on any entity ( scripted or not ) it is applied on.

Examples

Example

Don't draw the entity we've picked if we're its owner.

local function DontDrawMe( self )
	if self:GetOwner() == LocalPlayer() then
		return
	end
	
	self:DrawModel()
end

local pickent = Entity(1):GetEyeTrace().Entity

if ( IsValid( pickent ) ) then
	pickent.RenderOverride = DontDrawMe
end


Personal tools
Navigation