Entity/GetPos

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Lol)
 
Line 13: Line 13:
 
|Description=Utility command that would give you the position of the entity you are looking at.
 
|Description=Utility command that would give you the position of the entity you are looking at.
 
|Code=concommand.Add( "entity_pos", function( ply )
 
|Code=concommand.Add( "entity_pos", function( ply )
local ply:GetEyeTrace()
+
local tr = ply:GetEyeTrace()
 
if ( IsValid( tr.Entity ) ) then
 
if ( IsValid( tr.Entity ) ) then
 
print( "Entity position:", tr.Entity:GetPos() )
 
print( "Entity position:", tr.Entity:GetPos() )

Latest revision as of 21:54, 13 May 2016

 Entity:GetPos( )

Contents

Description

Gets the position of entity in world.

Returns

Vector

The position of the entity.

Examples

Example

Utility command that would give you the position of the entity you are looking at.

concommand.Add( "entity_pos", function( ply )
	local tr = ply:GetEyeTrace()
	if ( IsValid( tr.Entity ) ) then
		print( "Entity position:", tr.Entity:GetPos() )
	else
		print( "Crosshair position:", tr.HitPos )
	end
end )


Personal tools
Navigation