Damage Data
The DamageData struct encapsulates all the details of a damage instance. It is passed between systems like Hitbox, ProjectileAmmo, and Health.
Summary
This struct:
- Holds the amount and position of damage
- Tracks the instigator (e.g., shooter, attacker)
- Supports fallbacks and validation
Fields
| Field | Type | Description |
|---|---|---|
damagePoints | float | Amount of damage to apply. |
hitPoint | Vector3 | Position where the hit occurred. |
hitNormal | Vector3 | Surface normal at the hit point (for physics or VFX). |
instigator | GameObject | The entity that caused the damage. |
Static Members
| Member | Description |
|---|---|
DamageData Empty | Returns an empty DamageData with all fields zero/null. |
bool IsEmpty(DamageData damageData) | Returns true if the DamageData is empty. |
Constructors
| Constructor | Description |
|---|---|
DamageData(DamageData data) | Copies data from another instance. |
Usage
Tip
Use this struct when applying damage from projectiles, raycasts, or melee hits.
Note
Add fields like damageType, critChance, or sourceWeapon if your system needs more context.