ENTITY/RenderOverride

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m (Spacing)
 
(12 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
{{Hook
 
{{Hook
|Description=Called instead of the engine drawing function of the entity.
+
|Description=Called instead of the engine drawing function of the entity. This hook works on any entity (scripted or not) it is applied on.
  
This hook can be applied on any entity ( scripted or not ) it is applied on.
+
This does not work on "physgun_beam", use {{HookFunction|GM|DrawPhysgunBeam}} instead.
 +
 
 +
{{Note|As a downside of this implementation, only one RenderOverride may be applied at a time.}}
 +
 
 +
{{Bug|Issue=3292|Drawing a viewmodel in this function will cause {{HookFunction|GM|PreDrawViewModel}}, {{HookFunction|WEAPON|PreDrawViewModel}}, {{HookFunction|WEAPON|ViewModelDrawn}}, {{HookFunction|GM|PostDrawViewModel}}, and {{HookFunction|WEAPON|PostDrawViewModel}} to be called twice.}}
 +
 
 +
{{Bug|Issue=3299|This is called before PrePlayerDraw for players. If this function exists at all on a player, their worldmodel will always be rendered regardless of PrePlayerDraw's return.}}
 
|Realm=Client
 
|Realm=Client
 
|Predicted=No
 
|Predicted=No
|Name=RenderOverride
+
}}
|Parent=ENTITY
+
{{Example
 +
|Description=Set the entity the player is looking at to not draw if the player is its owner.
 +
|Code=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
 
}}
 
}}

Latest revision as of 22:18, 26 July 2018

 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.

This does not work on "physgun_beam", use GM:DrawPhysgunBeam instead.

NOTE

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

BUG

Drawing a viewmodel in this function will cause GM:PreDrawViewModel, WEAPON:PreDrawViewModel, WEAPON:ViewModelDrawn, GM:PostDrawViewModel, and WEAPON:PostDrawViewModel to be called twice.

Issue Tracker: #3292

BUG

This is called before PrePlayerDraw for players. If this function exists at all on a player, their worldmodel will always be rendered regardless of PrePlayerDraw's return.

Issue Tracker: #3299

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