PlayerHealthController

PlayerHealthController
The PlayerHealthController is a script on the root of the Player that is responsible for killing the player, and respawning.

It relies on Health script on the same GameObject that implements IHittable and takes damage, and optionally death, when OnProjectileHit is called.

The script hooks onDeath on Health to a KillPlayer method that is responsible for killing and disabling the player.

Kill is networked because the stick method on the Projectile is networked to all player from the player that is hit, if it hits a player.

The kill method stops interacting with any intractables in the player's hands and respawns any weapons.

As well as disabling the teleporters and interaction from the hands.

It also removes any projectile that are stuck to the player.

The kill animation is enabling the rigidbody on all the body parts on the player so the player appears to fall apart.

It also tests if a player has won the game, and begins the respawn timer.

When the timer is over the player can press a button to respawn. Which resets the player and picks a spawn position over the network.