|
Table of Contents
|
Part of World Components
VRC Combat System
The Combat System is how you can easily give players health and ragdoll players on death. The combat system is paired with a prefab with the VRC_VisualDamage component. As players lose health, this prefab will shrink to be shown in front of the player's face. You cannot disable the combat system itself when it is added to your world and it must be enabled at start to be usable. You can use the Add Damage trigger action to damage players and the Add Health trigger action to heal them. See Combat Guide for more details on different methods of combat weapons.
The combat system will add a Rigidbody and collider to all humanoid bones on your avatar. While it was meant for the ragdoll on player death, it also means that your hands can push objects without grabbing them.
Options
| Parameter | Description |
|---|---|
| maxPlayerHealth | A float, representing the maximum health a player can have. |
| respawnOnDeath | If true, players will automatically respawn to the respawnPoint post death, after repawnTime. If false, respawn must be handled manually using the RespawnPlayer RPC. |
| respawnPoint | A GameObject representing where players will respawn on death. If this is not set, players will respawn to their current location |
| respawnTime | A float, representing the amount of time after player death, after which the player will respawn at the respawnPoint. |
| resetHealthOnRespawn | If true, players' health will be set to maxPlayerHealth upon respawning. If false, players will not be able to die again until they are healed first using AddHealth trigger. |
| visualDamagePrefab | A GameObject that spawns on the player's camera. When a player takes damage this object will change size based on the VRC_VisualDamage component's parameters. If empty, there is a default damage indicator. |
| onPlayerKilledTrigger | A trigger that is called with a player's health reaches zero. |
| onPlayerHealedTrigger | A trigger that is called when a player is healed. |
| onPlayerDamagedTrigger | A trigger that is called when a player takes damage. |
Combat System and Triggers
| RPC | Description |
|---|---|
| RespawnPlayer | Calling this will respawn the player if they have died and have not been healed. You would only need to call this if you have respawnOnDeath set to false. This can only be called by the local player and must be set to local broadcast. |
Tips
While the combat system makes setting up a combat map easier, the only thing that it offers that cannot be done otherwise is giving player avatars a ragdoll. Using animators and parameters, you can setup your own health system. Typically advanced creators will create their own animator health systems to also display a player's current health which is not possible through the combat system directly. Using this method, the combat system would only be used to ragdoll the player. Health bars are usually displayed either above the player's head or on their face as HUD. See Player Tracking for more details on HUDs and tracking the player's camera position.
Known Issues
Adding a combat system to your map will break all Rigidbodies on avatars.