util/TraceEntity

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m
Line 2: Line 2:
 
|Name=TraceEntity
 
|Name=TraceEntity
 
|Parent=util
 
|Parent=util
|Description=Runs a trace using the ent's collisionmodel between two points, returning a {{Struct| TraceRes}}
+
|Description=Runs a trace using the ent's collisionmodel between two points.
 
|Realm=Shared
 
|Realm=Shared
 
|IsClass=No
 
|IsClass=No
Line 9: Line 9:
 
|type=table
 
|type=table
 
|name=tracedata
 
|name=tracedata
|desc=The {{Struct|Trace}}
+
|desc=Trace data. See {{Struct|Trace}}
 
}}
 
}}
 
{{Arg
 
{{Arg
Line 18: Line 18:
 
{{Ret
 
{{Ret
 
|type=table
 
|type=table
|desc=traceRes
+
|desc=Trace result. See {{Struct|TraceResult}}
 
}}
 
}}
 
{{Example
 
{{Example
Line 25: Line 25:
 
local tr = util.TraceEntity( trace, ent )  
 
local tr = util.TraceEntity( trace, ent )  
 
if ( tr.Hit ) then
 
if ( tr.Hit ) then
  ...
+
  -- Do stuff
 +
end
 
}}
 
}}

Revision as of 10:10, 21 October 2013

 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

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