PlayerController: Built-in First/Third Person Controller with Physics, Input, and Camera
The PlayerController component is a first and third person player controller built into s&box. It is physics-based (a special RigidBody) with built-in input, camera, and animator features that can each be optionally disabled.
Physics Based
At its core it's a special RigidBody in the physics system with all the same properties (velocity, mass) plus extras for controllability.
Input
The owner can control it using mouse, keyboard, or game controller. Without built-in input, control it in OnFixedUpdate by changing EyeAngles and WishVelocity. The input feature is optional and can be disabled.
Camera
Built-in third person and first person camera with toggle support. Optional feature.
Animator
Built-in animator for anything with a Citizen-compatible AnimGraph. Optional feature.
Events Interface
Listen to PlayerController events by implementing PlayerController.IEvents on a sibling Component:
public interface IEvents : ISceneEvent<IEvents>
{
void OnEyeAngles( ref Angles angles ) { }
void PostCameraSetup( CameraComponent cam ) { }
void OnJumped() { }
void OnLanded( float distance, Vector3 impactVelocity ) { }
Component GetUsableComponent( GameObject go ) { return default; }
void StartPressing( Component target ) { }
void StopPressing( Component target ) { }
void FailPressing() { }
}Events include eye angle changes, camera setup, jump, land, and use/interact system callbacks.