Getpos: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (Added the page to the category 'Console Commands')
(Added a table for other commands/convars related to getting/setting positions.)
Line 1: Line 1:
{{DISPLAYTITLE:getpos}}
{{DISPLAYTITLE:getpos}}
{{ent|getpos}} is a console command that prints the player's position and view angle in the console in XYZ tuples.
{{ent|getpos}} is a [[console command]] available in all {{game name|src|name=Source}} games. It prints the local [[player]]'s position and [[QAngle|view angle]] in the [[console]] in XYZ tuples.


A typical output looks like this:
A typical output looks like this:
<pre>
<pre style="background-color:#444; border-color:#666; color:#ddd">
setpos 8415.820313 -5248.870117 320.000000;setang -70.642090 71.564941 0.000000
setpos 8415.820313 -5248.870117 320.000000;setang -70.642090 71.564941 0.000000
</pre>
</pre>


==setpos and setang==
The <code>setpos</code> and <code>;setang</code> parts in the output above are for convenience; These are also console commands used for setting the player position and viewing angle. This lets the user copy the entire output line and paste it back into the console if they want to go to that exact spot again.
The <code>setpos</code> and <code>;setang</code> parts in the output above are for convenience; these are also console commands, used for setting the player position and viewing angle. This lets the user copy the entire output line and paste it back into the console if they want to go to that exact spot again.
{{note|When using <code>setpos</code> you may need to enable {{ent|noclip}} to get to a position that would make the player become stuck inside something or when teleporting outside of the map.}}
{{note|When using <code>setpos</code> you may need to enable {{ent|noclip}} to get to a position that would make the player become stuck inside something or when teleporting outside of the map.}}


These two commands also have <code>_exact</code> variations.
{{note|The commands for ''setting'' the player's position or angles require {{ent|sv_cheats|1}}. The commands/convars for ''getting'' the player's position or angles don't require that, except for {{csgo}}.}}
*<code>setpos_exact</code> will automatically enable <code>noclip</code> if moving to a position that would make the player become stuck inside something or when teleporting outside of the map. Entities such as triggers, children and even the player entity itself will acknowledge when this command is used and may react to its use, unlike <code>setpos</code>.
 
*<code>setang_exact</code> works basically the same. Entities such as triggers, children and even the player entity itself will acknowledge when this command is used and may react to its use, unlike <code>setang</code>.
{| class=standard-table
! Console Command and Usage
! Availability{{confirm}}
! Description
|- id="getpos"
| <code>getpos</code>
| {{since|{{hl2}}}}
| Prints the local player's '''eye position''' (!) and angles.
|- id="setpos"
| <code>setpos x y <z optional></code>
| {{since|{{hl2}}}}
| Move player to specified origin (must have sv_cheats).
|- id="setang"
| <code>setang p y <r optional></code>
| {{since|{{hl2}}}}
| Snap player eyes and orientation to specified pitch yaw <roll:optional> (must have sv_cheats).
|-
! !! !!
|- id="getpos_exact"
| <code>getpos_exact</code>
| {{l4d}}{{l4d2}}{{dota2}}{{as}}{{asrd}}{{portal2}}{{csgo}}{{ddd}}{{con}}
| Prints the local player's '''origin''' (!) and angles.
|- id="setpos_exact"
| <code>setpos_exact x y <z optional></code>
| {{since|{{hl2}}}}
| Will automatically enable <code>noclip</code> if moving to a position that would make the player become stuck inside something or when teleporting outside of the map. Entities such as [[triggers]], [[children]] and even the player entity itself will acknowledge when this command is used and may react to its use, unlike <code>setpos</code>.
|- id="setang_exact"
| <code>setang_exact p y <r optional></code>
| {{since|{{hl2}}}}
| Works basically the same. Entities such as triggers, children and even the player entity itself will acknowledge when this command is used and may react to its use, unlike <code>setang</code>.  
|-
! !! !!
|- id="setpos_player"
|style=white-space:nowrap| <code>setpos_player player_index x y <z optional></code>
| {{l4d}}{{l4d2}}{{dota2}}{{as}}{{asrd}}{{portal2}}{{csgo}}{{ddd}}{{con}}
| Move specified player to specified origin (must have sv_cheats).
|}
 
{| class=standard-table
! Console Variable
! Availability
! Description
|- id="cl_showpos"
| <code>cl_showpos</code>
| {{since|{{hl2}}}}
| Draw current position at top of screen.
|}


[[Category: Console Commands]]
[[Category: Console Commands]]
[[Category: Core Console Commands]]

Revision as of 20:32, 24 February 2022

getpos is a console command available in all Template:Game name games. It prints the local player's position and view angle in the console in XYZ tuples.

A typical output looks like this:

setpos 8415.820313 -5248.870117 320.000000;setang -70.642090 71.564941 0.000000

The setpos and ;setang parts in the output above are for convenience; These are also console commands used for setting the player position and viewing angle. This lets the user copy the entire output line and paste it back into the console if they want to go to that exact spot again.

Note.pngNote:When using setpos you may need to enable noclip to get to a position that would make the player become stuck inside something or when teleporting outside of the map.
Note.pngNote:The commands for setting the player's position or angles require sv_cheats 1. The commands/convars for getting the player's position or angles don't require that, except for Counter-Strike: Global Offensive.
Console Command and Usage Availability[confirm] Description
getpos (in all games since Half-Life 2) Prints the local player's eye position (!) and angles.
setpos x y <z optional> (in all games since Half-Life 2) Move player to specified origin (must have sv_cheats).
setang p y <r optional> (in all games since Half-Life 2) Snap player eyes and orientation to specified pitch yaw <roll:optional> (must have sv_cheats).
getpos_exact Left 4 DeadLeft 4 Dead 2Dota 2Alien SwarmAlien Swarm: Reactive DropPortal 2Counter-Strike: Global OffensiveDino D-DayContagion Prints the local player's origin (!) and angles.
setpos_exact x y <z optional> (in all games since Half-Life 2) Will automatically enable noclip if moving to a position that would make the player become stuck inside something or when teleporting outside of the map. Entities such as triggers, children and even the player entity itself will acknowledge when this command is used and may react to its use, unlike setpos.
setang_exact p y <r optional> (in all games since Half-Life 2) Works basically the same. Entities such as triggers, children and even the player entity itself will acknowledge when this command is used and may react to its use, unlike setang.
setpos_player player_index x y <z optional> Left 4 DeadLeft 4 Dead 2Dota 2Alien SwarmAlien Swarm: Reactive DropPortal 2Counter-Strike: Global OffensiveDino D-DayContagion Move specified player to specified origin (must have sv_cheats).
Console Variable Availability Description
cl_showpos (in all games since Half-Life 2) Draw current position at top of screen.