Player Setup
Configure the three stat-tracking components on the player GameObject: PlayerHealth, PlayerStamina, and ActiveEffectsController. All three belong on the same root object as PlayerController.
1. Add PlayerHealth
Select the player root GameObject and add the PlayerHealth component.
- Set Max Health to the starting maximum hit points.
- Assign Impact Sound, Block Sound, and Die Sound audio clips.
- Assign the Stat asset that represents health so equipment bonuses can be applied at runtime.
Wire the HUD in the Inspector:
PlayerHealth.OnInitialize→PlayerHealthBar.InitializePlayerHealth.OnHealthUpdated→PlayerHealthBar.UpdateHealthPlayerHealth.OnDie→ any game-over handler (e.g.LevelManager.OnPlayerDeath)
See Health for the full event reference.
2. Add PlayerStamina
Add PlayerStamina to the same GameObject.
- Assign the Stat asset that represents stamina.
Wire the HUD:
PlayerStamina.OnInitialize→PlayerStaminaBar.InitializePlayerStamina.OnValueUpdated→PlayerStaminaBar.UpdatePoints
See PlayerStamina for the full event and method reference.
3. Add ActiveEffectsController
Add ActiveEffectsController to the same GameObject. No Inspector fields need to be filled — the controller wires itself to the other player components at runtime and tracks timed stat effects automatically.
See ActiveEffectsController for details on how timed effects are tracked and reverted.
4. Add execution subscribers (optional)
IExecutionSuscriber components placed on the player's root GameObject or any of its children are auto-discovered by PlayerController during initialization. Their Execute() method is called every time the player executes an instruction step — no manual wiring needed.
Common uses on the player:
- Playing an action sound or VFX on every instruction.
- Firing a projectile via
ShootSuscriber— identical setup to enemies, just attach it to the player hierarchy instead. - Any custom side-effect that should happen on every player instruction without modifying the
Instructionclass itself.
// PlayerController.Initialize() — runs automatically at level start IExecutionSuscriber[] suscribers = GetComponentsInChildren<IExecutionSuscriber>(); foreach (IExecutionSuscriber s in suscribers) OnExecute += s.Execute;
ctx.player.health and ctx.player.stamina. You do not need to hold a manual reference — the ExecutionContext exposes them automatically.