Getpos: Difference between revisions
(Added a table for other commands/convars related to getting/setting positions.) |
(Added spec_pos. getpos and spec_pos have a different effect when given the parameter "2".) |
||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:getpos}} | {{DISPLAYTITLE:getpos}} | ||
{{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. | {{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. | ||
The output format is <code>"setpos <x> <y> <z>;setang <pitch> <yaw> <roll>"</code>. | |||
The <code>setpos</code> and <code>;setang</code> parts 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. | |||
A typical output looks like this: | A typical output looks like this: | ||
{{pre| | |||
] getpos | |||
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 | }} | ||
If you don't want the <code>setpos</code> and <code>setang</code> in the output, use '''<code>spec_pos</code>'''. | |||
{{pre| | |||
] spec_pos | |||
spec_goto 8415.8 -5248.9 320.0 -70.6 71.6 | |||
}} | |||
{{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.}} | ||
{{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}}.}} | {{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}}.}} | ||
{| class= | {{important| | ||
The difference between {{mdCode|getpos}} and {{mdCode|getpos_exact}} ({{=}} {{mdCode|getpos 2}}) is the z-height: The former returns the local player's '''eye position''' and the latter their '''origin'''. These locations are identical for spectators but not for regular players. If you are not spectating and you want to reproduce your current location, you have to use {{mdCode|getpos_exact}} and not <code>getpos</code>. For spectators, both commands return the same result. | |||
The difference between {{mdCode|setpos}} and {{mdCode|setpos_exact}} is just whether or not entitys will react to the player's new position. Both commands always set the player's '''origin''', so if you are not spectating, your eye position will have a higher z-height than the z-coordinate that you have entered. | |||
}} | |||
{| class=wikitable | |||
! Console Command and Usage | ! Console Command and Usage | ||
! Description | ! Description | ||
|- id="getpos" | |- id="getpos" | ||
| <code>getpos</code> | | {{mdCode|getpos}} | ||
| {{since|{{ | | Prints the local player's '''eye position''' and angles. Invoking the output will put '''a spectator''' into the same position. | ||
| | |- | ||
| {{mdCode|getpos 2}} | |||
| Prints the local player's '''origin''' and angles. Invoking the output will put '''any player''' into the same position. {{bug|{{csgo}} The returned pitch is always 0. Use <code>getpos</code> to actually obtain that value.}} | |||
|- id="getpos_exact" | |||
| {{mdCode|getpos_exact}} {{l4d|since}} | |||
| Equivalent to {{mdCode|getpos 2}}. | |||
|- id="spec_pos" | |||
| {{mdCode|spec_pos}} | |||
|rowspan=2| Equivalent to {{mdCode|getpos}} and {{mdCode|getpos 2}} respectively but prints the values in the format <code style=white-space:nowrap>"spec_goto <x> <y> <z> <pitch> <yaw>"</code> and with just one decimal place for each of the five numbers. The roll value is omitted. {{csgo}} Does not print the prefix <code>"spec_goto"</code>. | |||
|- id="spec_pos" | |||
|{{mdCode|spec_pos 2}} | |||
|- id="setpos" | |- id="setpos" | ||
| < | | {{mdCode|setpos <x> <y> [z optional]}} | ||
| Move player's '''origin''' to the specified coordinates. The resulting eye position may be higher. | |||
| Move player to specified | |||
|- id="setang" | |- id="setang" | ||
| | | {{mdCode|setang <pitch> <yaw> [roll optional]}} | ||
| Snap player's eyes and orientation to specified angles. | |||
| Snap player eyes and orientation to specified | |||
|- id="setpos_exact" | |- id="setpos_exact" | ||
| < | | {{mdCode|setpos_exact <x> <y> [z optional]}} | ||
|rowspan=2| Equivalent to <code>setpos</code> or <code>setang</code> respectively, but 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. | |||
|- id="setang_exact" | |- id="setang_exact" | ||
| | | {{mdCode|setang_exact <pitch> <yaw> [roll optional]}} | ||
|- id="setpos_player" | |- id="setpos_player" | ||
|style=white-space:nowrap| < | |style=white-space:nowrap| {{mdCode|setpos_player <player_index> <x> <y> [z optional]}} | ||
:{{l4d|since}} | |||
| | | Moves the specified player to the specified origin, like {{mdCode|setpos}}. | ||
|} | |} | ||
{| class= | {| class=wikitable | ||
! Console Variable | ! Console Variable | ||
! Description | ! Description | ||
|- id="cl_showpos" | |- id="cl_showpos" | ||
| {{mdCode|cl_showpos}} | |||
| {{ | | If non-zero, draws the local player's current eye position, angles and velocity at the top of the screen. | ||
| | |||
|} | |} | ||
[[Category: Console Commands]] | [[Category: Console Commands]] | ||
[[Category: Core Console Commands]] | [[Category: Core Console Commands]] |
Revision as of 22:29, 29 December 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.
The output format is "setpos <x> <y> <z>;setang <pitch> <yaw> <roll>"
.
The setpos
and ;setang
parts 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.
A typical output looks like this:
] getpos setpos 8415.820313 -5248.870117 320.000000;setang -70.642090 71.564941 0.000000
If you don't want the setpos
and setang
in the output, use spec_pos
.
] spec_pos spec_goto 8415.8 -5248.9 320.0 -70.6 71.6

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.


The difference between getpos
and getpos_exact
(= getpos 2
) is the z-height: The former returns the local player's eye position and the latter their origin. These locations are identical for spectators but not for regular players. If you are not spectating and you want to reproduce your current location, you have to use getpos_exact
and not getpos
. For spectators, both commands return the same result.
The difference between setpos
and setpos_exact
is just whether or not entitys will react to the player's new position. Both commands always set the player's origin, so if you are not spectating, your eye position will have a higher z-height than the z-coordinate that you have entered.
Console Command and Usage | Description |
---|---|
getpos
|
Prints the local player's eye position and angles. Invoking the output will put a spectator into the same position. |
getpos 2
|
Prints the local player's origin and angles. Invoking the output will put any player into the same position. ![]() ![]() getpos to actually obtain that value. [todo tested in ?] |
getpos_exact (in all games since ![]() |
Equivalent to getpos 2 .
|
spec_pos
|
Equivalent to getpos and getpos 2 respectively but prints the values in the format "spec_goto <x> <y> <z> <pitch> <yaw>" and with just one decimal place for each of the five numbers. The roll value is omitted. ![]() "spec_goto" .
|
spec_pos 2
| |
setpos <x> <y> [z optional]
|
Move player's origin to the specified coordinates. The resulting eye position may be higher. |
setang <pitch> <yaw> [roll optional]
|
Snap player's eyes and orientation to specified angles. |
setpos_exact <x> <y> [z optional]
|
Equivalent to setpos or setang respectively, but 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.
|
setang_exact <pitch> <yaw> [roll optional]
| |
setpos_player <player_index> <x> <y> [z optional]
|
Moves the specified player to the specified origin, like setpos .
|
Console Variable | Description |
---|---|
cl_showpos
|
If non-zero, draws the local player's current eye position, angles and velocity at the top of the screen. |