util/TraceEntity

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Created page with "{{Func |Name=TraceEntity |Parent=util |Description=Runs a trace using the ent's collisionmodel between two points, returning a {{Struct| TraceRes}} |Realm=Shared |IsClass...")
 
(Changed arguments to correct order)
Line 5: Line 5:
 
|Realm=Shared
 
|Realm=Shared
 
|IsClass=No
 
|IsClass=No
}}
 
{{Arg
 
|type=Entity
 
|name=ent
 
|desc=The entity to use
 
 
}}
 
}}
 
{{Arg
 
{{Arg
Line 15: Line 10:
 
|name=tracedata
 
|name=tracedata
 
|desc=The {{Struct| Trace}}
 
|desc=The {{Struct| Trace}}
 +
}}
 +
{{Arg
 +
|type=Entity
 +
|name=ent
 +
|desc=The entity to use
 
}}
 
}}
 
{{Ret
 
{{Ret
 
|type=table
 
|type=table
|desc= traceRes
+
|desc=traceRes
 
}}
 
}}
 
{{Example
 
{{Example
| Description = From sandbox/gamemode/prop_tools.lua, this checks if there are any entities inside our entity
+
|Description=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 )  
 
if ( tr.Hit ) then
 
if ( tr.Hit ) then
 
  ...
 
  ...
 
}}
 
}}

Revision as of 22:34, 20 June 2013

 util.TraceEntity( )

Contents

Description

Runs a trace using the ent's collisionmodel between two points, returning a TraceRes structure

Arguments

table tracedata

Arguments

Entity ent

The entity to use

Returns

table

traceRes

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
 ...


Personal tools
Navigation