Libraries

s&box libraries list

Shrimple Pawns

fish.sp

The classic entity pawn system... but in scene!

About

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
{

}

then assign the pawn to the client!

// All of the following code should be called on the host! Since we use [HostSync] internally.
//
// Setup and assign the client a connection. Make sure this clientObj is already networked and has a client component attached.
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);

// Option #3
// The gameobject already exists and you want to assign it
var obj = SceneUtility.GetPrefabScene( SpectatePrefab ).Clone();
client.AssignPawn(obj);


A full example can be viewed here.

More by Small Fish

04
Conchplex Particle Emitters thumbnail
Conchplex Particle Emitters fish.conchplexemitters

Sphere, Box and Ring emitters, with additional functionality and more easier to understand property names and layout.

+0 24h
1favorites
2upvotes
43%Terry score