CrimsonNumberPop · Lesson 5 of 8
Replicate & Broadcast
Before you start
- Completed: Create the Pop Widget & Point Settings
Chapters
1. Add the replication component
Add `CrimsonNumberPopReplicationComponent` to your Game State — Add Component in Blueprint, CreateDefaultSubobject in C++. It self-registers 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 FCrimsonNumberPopEvent — Value, Tags (what the registry matches on), Target, optional Instigator, Prefix Text, or Custom Text — and call Broadcast Number Pop.
FCrimsonNumberPopEvent Event;Event.Value = Damage;Event.Tags.AddTag(TAG_Damage_Crit);Event.Target = TargetActor;Event.Instigator = SourceActor;GameState->FindComponentByClass<UCrimsonNumberPopReplicationComponent>()->BroadcastNumberPop(Event);
Safe from shared code
BroadcastNumberPop validates HasAuthority() internally — calling it from code that also runs on clients is a no-op there, not a bug.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.