util/TraceEntity

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
 
{{Func
 
{{Func
|Name=TraceEntity
 
|Parent=util
 
 
|Description=Runs a trace using the ent's collisionmodel between two points.
 
|Description=Runs a trace using the ent's collisionmodel between two points.
 
|Realm=Shared
 
|Realm=Shared
Line 21: Line 19:
 
}}
 
}}
 
{{Example
 
{{Example
|Description=From sandbox/gamemode/prop_tools.lua, this checks if there are any entities inside our entity
+
|Description={{Note|This example doesn't actually work. See sandbox/gamemode/commands.lua}}
 +
 
 +
From sandbox/gamemode/prop_tools.lua, this checks if there are any entities inside our entity
 
|Code=local trace = { start = ent:GetPos(), endpos = ent:GetPos(), filter = ent }
 
|Code=local trace = { start = ent:GetPos(), endpos = ent:GetPos(), filter = ent }
 
local tr = util.TraceEntity( trace, ent )  
 
local tr = util.TraceEntity( trace, ent )  

Revision as of 03:34, 9 March 2018

 util.TraceEntity( )

Contents

Description

Runs a trace using the ent's collisionmodel between two points.

Arguments

table tracedata

Trace data. See Trace structure

Arguments

Entity ent

The entity to use

Returns

table

Trace result. See TraceResult structure

Examples

Example

NOTE

This example doesn't actually work. See sandbox/gamemode/commands.lua

From sandbox/gamemode/prop_tools.lua, this checks if there are any entities inside our entity

local trace = { start = ent:GetPos(), endpos = ent:GetPos(), filter = ent }
local tr = util.TraceEntity( trace, ent ) 
if ( tr.Hit ) then
 -- Do stuff
end


Personal tools
Navigation