Damage Data
DamageData is a struct describing one change to health: a hit, an explosion or a heal. It is passed from attacks to Hitbox, Health, modifiers and events.
Fields
| Field | Type | Description |
|---|---|---|
damagePoints | float | Amount of health to change. |
hitPoint | Vector3 | Where the hit landed. |
hitNormal | Vector3 | Surface normal at the hit. |
instigator | GameObject | The object that caused the change, e.g. the shooter. |
Members
| Member | Description |
|---|---|
static DamageData Empty | A DamageData with zero damage, zero vectors and no instigator. |
DamageData(DamageData data) | Creates a copy of another DamageData. |
static bool IsEmpty(DamageData damageData) | True if the damage, hit point and instigator match Empty. |
Example
var damage = new DamageData
{
damagePoints = 30f,
hitPoint = hit.point,
hitNormal = hit.normal,
instigator = gameObject,
};Tip
Use instigator in an OnDeath listener to award points to whoever landed the killing blow.