CrimsonCombatText · Lesson 5 of 8
Replicate & Broadcast
Before you start
- Completed: Create the Combat Text Widget & Point Settings
Chapters
1. Add the replication component
Add `CrimsonCombatTextReplicationComponent` to your Game State — Add Component in Blueprint, CreateDefaultSubobject in C++. It registers itself with each client's subsystem in BeginPlay; there's nothing else to wire.
Game State, not Game Mode
The Game Mode exists only on the server — a component there can never reach clients. This is the classic mistake; the Game State replicates to everyone, which is exactly what a broadcast needs.
2. Build the event and broadcast
Where damage resolves on the server (an AttributeSet's PostGameplayEffectExecute, a Take Damage handler), fill a FCrimsonCombatTextEvent — Value, Tags (matched by the registry and the per-player filters), Target (the server resolves the pop location from it), optional Instigator, Prefix Text, or Custom Text — and call Broadcast Combat Text.
// Server-side, e.g. in your AttributeSet's PostGameplayEffectExecute:if (AGameStateBase* GS = GetWorld()->GetGameState()){if (auto* Pops = GS->FindComponentByClass<UCrimsonCombatTextReplicationComponent>()){FCrimsonCombatTextEvent Event;Event.Value = FMath::Abs(Delta);Event.Tags.AddTag(DamageTag);Event.Target = TargetActor;Event.Instigator = DamageDealer;Pops->BroadcastCombatText(Event);}}
Safe from shared code
BroadcastCombatText validates HasAuthority() internally — calling it from code that also runs on clients is a no-op with a warning, not a bug. On listen servers and in singleplayer the local player is a client of the multicast like any other, so this one path covers every net mode.Verify
In a Listen Server + Client PIE session, deal damage on the server — the number pops on both screens, styled by whichever rule its tags matched.