Health and Damage
Overview
Character health and damage are handler by 2 elements in NeoFPS: A health manager and a number of damage handlers. Damage handlers react to damage from weapons and other scripts, modify that damage, and then pass it on to the health manager. For more information, see the BasicDamageHandler and EventDamageHandler.
Incoming damage can have a source attached, which can be used to work out the position or direction damage came from as well as the type of damage.
Health Pickups
Characters can regain health by collecting health pickups. These have a number of options for how they heal, and can be applied to either interactive objects, or trigger based pickups. The simplest way to create a health pickup is using the Pickup Wizard in the NeoFPS Hub.
Shields & Armour
Alongside health, NeoFPS has systems for simple energy shields and inventory based armour. When the character or object takes damage, first shields will absorb that damage until they are depleted, then armour will mitigate some of the damage (and be destroyed in the process).
Shields require the character to have a ShieldSystem behaviour attached, and the damage handlers are replaced with ShieldedDamageHandlers. You can then specify a number of shield steps, each with a set charge. Damage is taken from each step in order, and if any step is not fully broken it will recharge after a set period. To restore broken steps you can use a ShieldPickup.
Armour is implemented by using ArmouredDamageHandler components. These allow you to specify the inventory key for an armour item, and then any damage will be (partially) absorbed and taken away from that inventory item instead.
If you want to use both shields and armour, you can use the ShieldedArmouredDamageHandler.
The simplest way to create shield booster pickups or armour (inventory item) pickups is using the Pickup Wizard in the NeoFPS Hub.
Healing and Damage Zones
You can define areas that heal or damage characters over time by using the HealZone and DamageZone behaviours.
Damage Filters
Damage in NeoFPS can be filtered by team and by type. This allows for gameplay mechanics such as ignoring friendly fire, or blocking damage from explosions but not bullets.
The damage filter can be used for up to 8 teams and 8 damage types.
Damage handlers have an incoming damage filter, while damage sources have an outgoing damage filter. In code a collision can be checked via the following code:
if (inDamageFilter.CollidesWith (sourceDamageFilter, friendlyFire))
{
// React to damage here
}
The friendly fire parameter is a bool
. If this is true then the team section of either filter will be ignored. If not then the team has to be valid as well as the damage type.
Damage Source
The damage source allows for feedback on the location of the source and, when combined with damage filters, effects such as returning damage to melee attackers.
The damage source specifies outgoing damage filter and the character controller if relevant.