Skip to content

Small-Fish-Dev/shrimple-pawns

Repository files navigation

Shrimple Pawns

"no we won't allow pawn games" -garry

s&box library that provides support for the classic entity Pawn system. This is useful in cases where the player can take control of different controllers. For example, an FPS game where you have the regular player state but also a spectating state.

Example

// Inherit the pawn component.
//
// Make sure to provide the PawnAttribute with a path to a prefab
// if you decide to use the template version of AssignPawn.
[Pawn( "spectate.prefab" )]
public sealed class SpectatePawn : Pawn
{

}
// All of the following code should be called on the host! Since we use [HostSync] internally.
//
// Setup and assign the client a connection.
var client = clientObj.Components.Get<Client>();
client.AssignConnection( channel );

// Give the client a pawn via one of the methods below.

// Option #1
// The pawn component MUST have PawnAttribute.
client.AssignPawn<SpectatePawn>();

// Option #2
// The pawn component does NOT need PawnAttribute in this case.
client.AssignPawn(SpectatePrefab);

A full example can be viewed here.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages