Structs:UserCmd
The UserCmd struct contains data related to the player's current inputs. This struct is defined as native, meaning the internals are handled in the C++ part of the engine and custom versions of this struct cannot be created.
Usage
Each player has their own UserCmd struct which is accessible with the cmd field of the PlayerInfo struct of that player.
Fields
- uint buttons
- A bit field that contains the currently pressed buttons from the list below.
- To check if a specific button is pressed, bitwise operators must be used, for example
if (<playerInfoPointer>.cmd.buttons & BT_ATTACK)will return true if the Fire button is present among any other possible buttons.
- int16 pitch
- (Need more info)
- int16 yaw
- (Need more info)
- int16 roll
- (Need more info)
- int16 forwardmove
- Forward/backward input.
- int16 sidemove
- Leftward/rightward input.
- int16 upmove
- Downward/upward input.
forwardmove, sidemove and upmove are in the [-32767, 32767] range. The range is there to account for the possible use of analog input, like gamepads. If keys are used for those inputs, they will set the field to the maximum possible value.
Buttons
The buttons field can contain the same internal button names as the ones that can be obtained by GetPlayerInput:
| Internal name in ZScript or ACS | Corresponding action |
|---|---|
| BT_FORWARD | Walk forward |
| BT_BACK | Walk backward |
| BT_LEFT | Turn left |
| BT_RIGHT | Turn right |
| BT_MOVELEFT | Strafe left |
| BT_MOVERIGHT | Strafe right |
| BT_ATTACK | Fire primary |
| BT_ALTATTACK | Fire secondary |
| BT_USE | Use/Open |
| BT_JUMP | Jump |
| BT_CROUCH | Crouch |
| BT_TURN180 | 180-degree turn |
| BT_RELOAD | Reload weapon |
| BT_ZOOM | Zoom weapon |
| BT_SPEED | Run/walk modifier |
| BT_RUN | Run/walk state |
| BT_STRAFE | Strafe modifier |
| BT_LOOKUP | Look up (Keyboard) |
| BT_LOOKDOWN | Look down (Keyboard) |
| BT_MOVEUP | Swim/fly upward |
| BT_MOVEDOWN | Swim/fly downward |
| BT_SHOWSCORES | Show multiplayer scoreboard |
| BT_USER1 | User-defined button 1 |
| BT_USER2 | User-defined button 2 |
| BT_USER3 | User-defined button 3 |
| BT_USER4 | User-defined button 4 |
BT_RUN reflects the running/walking state, not merely whether the speed button is pressed or not like the case with BT_SPEED. This distinction becomes evident when autorun is involved.
| Action | State | BT_SPEED | BT_RUN |
|---|---|---|---|
| Speed button not pressed; autorun disabled | Walking | Not set | Not set |
| Speed button pressed; autorun disabled | Running | Set | Set |
| Speed button not pressed; autorun enabled | Running | Not set | Set |
| Speed button pressed; autorun enabled | Walking | Set | Not set |