S&box Wiki

History for Pawn

Revision Difference


<cat>Code.Player</cat> <title>Pawn</title> # What is a Pawn A Pawn is an Entity any Client (player) can possess, this is the physical representation of your player within the world. This entity doesn't need to be anything specific, you can make it a physics object or a traditional animated player. When a Client possesses a Pawn additional methods become active on the Entity: - `Simulate( Client )` - Called each tick serverside and clientside, this is <page text="predicted">Prediction</page>. - `FrameSimulate( Client )` - Called each frame on the client only to simulate things that need to be updated every frame. - `BuildInput( InputBuilder )` - Called every frame on the client to process input for your pawn. - `PostCameraSetup( ref CameraSetup )` There are several examples on how to use pawns in various ways: - [sbox-minimal](https://github.com/Facepunch/sbox-minimal/blob/master/code/MinimalPlayer.cs) - a basic standard player pawn - [sbox-netlab](https://github.com/Facepunch/sbox-netlab/blob/master/code/LabPawn.cs) - a more complex pawn controlling it's own animations and movement # Setting a Client's Pawn You can set the Client's Pawn at any point, a standard place to set it would be when the client first joins. ```csharp /// <summary> /// A client has joined the server. Make them a pawn to play with /// </summary> public override void ClientJoined( Client client ) { base.ClientJoined( client ); var player = new MinimalPlayer(); client.Pawn = player; player.Respawn(); } ```

Special Pages



Render Time: 42ms

DB GetPage 31
Get RevNew 2
Get RevOld 5
Render Body 0
Render Sidebar 1