util.GetPlayerTrace

From Garry's Mod
Jump to: navigation, search
 util.GetPlayerTrace( )

Contents

Description

Utility function to quickly generate a trace table that starts at the players view position, and ends 16384 units along a specified direction.

Arguments

Player ply

The player the trace should be based on

Arguments

Vector dir=ply:GetAimVector()

The direction of the trace

Returns

table

The trace data. See Trace structure

Examples

Example

Prints the entity's model the local player is looking at to console

local tr = util.TraceLine( util.GetPlayerTrace( LocalPlayer() ) )
if IsValid(tr.Entity) then print("I saw a "..tr.Entity:GetModel()) end

local trground = util.TraceLine( util.GetPlayerTrace( LocalPlayer(), Vector(0,0,-1) ) )
if IsValid(trground.Entity) then print("I'm standing on a "..trground.Entity:GetModel()) end


Personal tools
Navigation