Examples

The following scenarios demonstrate how the Damage System (DS), Armor System (AS) and Projectile System (PDS) work together in a typical game.


1. Damage + Armor Mitigation (C++ & Blueprint)

This setup shows a character taking damage that is first routed through armor. The core flow is:

  1. Projectile populates an FDamageContext and calls ProcessDamageEvent() on the target's UDamageRouterComponent.
  2. The router invokes UArmorSystemComponent::ProcessDamageInteraction() for mitigation.
  3. Remaining damage is applied to the ULimbSystemComponent / UCharacterAttributeSet.

The sequence shows:

  1. The player projectile hits the target.
  2. The target routes the hit to the Damage System.
  3. The Damage System consults the Armor System to reduce damage.
  4. Finally, the Limb Health System applies the remaining damage and effects.

C++ Component

CPP
// MyCharacter.cpp
void AMyCharacter::BeginPlay()
{
    Super::BeginPlay();

    DamageRouter = FindComponentByClass<UDamageRouterComponent>();
    ArmorSystem  = FindComponentByClass<UArmorSystemComponent>();
}

void AMyCharacter::ReceiveProjectileHit(const FDamageContext& InCtx)
{
    FDamageContext Context = InCtx;
    DamageRouter->ProcessDamageEvent(Context);
}

Blueprint Flow

  1. Create a Custom Event OnHitByProjectile taking an FDamageContext input.
  2. Call the above C++ function ReceiveProjectileHit.
  3. Add an Armor System Component and Damage Router Component to the Blueprint.
  4. The router handles mitigation and health updates automatically.

2. Spawning a Projectile in Blueprint

This example spawns a projectile actor and routes its damage through the DS.

  1. From your weapon Blueprint, Spawn Actor From Class using ABaseProjectile (or subclass).
  2. Set its Archetype property to a UProjectileArchetypeDataAsset.
  3. When the projectile impacts, it should call ProcessDamageEvent() on the hit actor:
CPP
// Inside ABaseProjectile::ProcessImpact()
FDamageContext Context;
Context.ProjectileMassKg  = Archetype->MassKg;
Context.ProjectileRoundType = Archetype->RoundType;
Context.CurrentDamageToApply = Archetype->BaseDamageAmount;
Context.DirectDamageEffectClassToApply = Archetype->DirectDamageGameplayEffectClass;

HitActor->FindComponentByClass<UDamageRouterComponent>()
    ->ProcessDamageEvent(Context);

The spawned projectile automatically uses the DS enums (ERoundType, EProjectileType) defined in DamageSystemTypes.h.


3. Attribute Data Table

Define a data table to initialize attributes in UCharacterAttributeSet.

CSV
Name,Health,MaxHealth,Stamina,MaxStamina
Default,100,100,50,50

Reference the table in code when initializing stats:

CPP
// Somewhere in character initialization
AbilitySystemComponent->InitStats(
    UCharacterAttributeSet::StaticClass(),
    AttributeDataTable
);

This allows designers to tweak starting values without recompiling.