Entity/GetPos

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Created page with "{{Func |Name=GetPos |Parent=Entity |Description=Gets the position of entity in world. | Returns = {{Return| Vector| pos}} |Realm=Shared |IsClass=Yes }} {{Ret |type=Vec...")
 
(Lol)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{Func
 
{{Func
|Name=GetPos
 
|Parent=Entity
 
 
|Description=Gets the position of entity in world.
 
|Description=Gets the position of entity in world.
| Returns = {{Return| Vector| pos}}
 
 
|Realm=Shared
 
|Realm=Shared
 
|IsClass=Yes
 
|IsClass=Yes
 +
|Name=GetPos
 +
|Parent=Entity
 
}}
 
}}
 
{{Ret
 
{{Ret
 
|type=Vector
 
|type=Vector
|desc= pos
+
|desc=The position of the entity.
 
}}
 
}}
 
{{Example
 
{{Example
| Description = Demonstrates the use of this function clientside.
+
|Description=Utility command that would give you the position of the entity you are looking at.
| Code = print( LocalPlayer():GetPos() )
+
|Code=concommand.Add( "entity_pos", function( ply )
| Output = Something like "529.396179 -779.646423 -110.303543".
+
local tr = ply:GetEyeTrace()
 +
if ( IsValid( tr.Entity ) ) then
 +
print( "Entity position:", tr.Entity:GetPos() )
 +
else
 +
print( "Crosshair position:", tr.HitPos )
 +
end
 +
end )
 
}}
 
}}

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