ENTITY/RenderOverride

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(this is clientside code, should use LocalPlayer)
(improved example description)
Line 9: Line 9:
 
}}
 
}}
 
{{Example
 
{{Example
|Description=Don't draw the entity we've picked if we're its owner.
+
|Description=Set the entity the player is looking at to not draw if the player is its owner.
 
|Code=local function DontDrawMe( self )
 
|Code=local function DontDrawMe( self )
 
if ( self:GetOwner() == LocalPlayer() ) then
 
if ( self:GetOwner() == LocalPlayer() ) then

Revision as of 12:12, 9 September 2017

 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.

NOTE

As a downside of this implementation, only one RenderOverride may be applied at a time

Examples

Example

Set the entity the player is looking at to not draw if the player is its owner.

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

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

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


Personal tools
Navigation