menu_bookDocumentation

DamageInfo: The Standard Damage Payload — Properties, Usage, and Custom Types

calendar_today May 4, 2026 schedule ~1 min read person patrickjr verified 50

DamageInfo: The Standard Damage Payload

DamageInfo is a class (not a struct) used to pass damage information between game systems. It is intentionally a class so games can derive from it to add custom damage types.

Properties

| Property | Type | Description | |---|---|---| | Damage | float | Amount of damage | | Attacker | GameObject | Who dealt the damage (player, NPC, etc.) | | Weapon | GameObject | What dealt the damage (weapon, vehicle, etc.) | | Hitbox | Hitbox | The hitbox that was hit (if any) | | Shape | PhysicsShape | The physics shape that was hit (if any) | | Origin | Vector3 | Source of the damage (shooter eye position, explosion center) | | Position | Vector3 | Location of the damage on the hit object | | Tags | TagSet | Damage type tags (e.g., "explosion", "fire", "bullet") |

Usage

CSHARP
// Create damage info
var damage = new DamageInfo( 50f, attackerGo, weaponGo );
damage.Origin = shooterEyePosition;
damage.Position = hitPosition;
damage.Tags.Add( "bullet" );

// Apply to a component that handles damage
var health = target.Components.Get<HealthComponent>();
health?.TakeDamage( damage );

Custom Damage Types

CSHARP
public class ExplosionDamage : DamageInfo
{
    public float BlastRadius { get; set; }
    public float Falloff { get; set; }

    public ExplosionDamage( float damage, float radius ) : base( damage, null, null )
    {
        BlastRadius = radius;
        Tags.Add( "explosion" );
    }
}

Checking Damage Type

CSHARP
void TakeDamage( DamageInfo info )
{
    if ( info.Tags.Has( "explosion" ) )
    {
        // Apply knockback
    }

    if ( info is ExplosionDamage explosion )
    {
        // Access custom properties
        Log.Info( $"Blast radius: {explosion.BlastRadius}" );
    }
}
Was this helpful?