What is a Player Controller
A PlayerController takes input from the user and moves the player.
The simplest controller is a noclip controller. It moves the player relative to the direction they're facing.
NoclipController : PlayerController
public override void
Rotation = Input
direction = new Vector3
direction *= Rotation;
direction = direction.Normal * 1000
Position += direction * Time
The PlayerController class has a number of persistent common properties such as Pos, Rot, Velocity, GroundEntity.
Setting these properties like Pos or Rot doesn't immediately change anything on the player. The new position is applied later. This means you can incrementally change these values and restore them without worry that you're going to leave the player in a weird state.
Setting The Player Controller
To set the player controller on a player you can set the Controller property. You can do this in Respawn, or the player's constructor.
public override void Respawn()
Controller = new NoclipController();
You can change this property at any point during the game to give the player a different controller. Or set it to null if you don't want the player to move.
You only need to set Controller server-side. The change will replicate to the client.
speed *= 0
eyesForward = Input
bWantsMove = Input
bWantsMove = bWantsMove || Input
Do's and Don'ts
The PlayerController shouldn't really ever access the player directly. It can, but it probably shouldn't.
The PlayerController is run on both the local client and the server.
When the Client gets the results from the server, it compares them. If they don't match it snaps the client back to what the server said it should be.
Your controller should always do exactly the same thing.