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

FieldTypeDescription
damagePointsfloatAmount of health to change.
hitPointVector3Where the hit landed.
hitNormalVector3Surface normal at the hit.
instigatorGameObjectThe object that caused the change, e.g. the shooter.

Members

MemberDescription
static DamageData EmptyA 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.