How-To: Broadcast & Listen for Messages

Goal: send a one-way, struct-typed event on a gameplay-tag channel and receive it elsewhere - no references between sender and receiver. Use it in your own project, for example to forward the delegates of several systems onto one channel tree.

Prerequisites
CrimsonCommon is enabled. Define (or pick) a USTRUCT payload and a GameplayTag channel both sides agree on.

1. Broadcast

Get the subsystem off any world context and broadcast your struct on a channel tag. Anyone listening on that channel (or a parent of it) receives a copy.

Right-click in any graph -> search Crimson Message Subsystem -> pick the getter under Game Instance Subsystems. Then: Get CrimsonMessageSubsystem -> Broadcast Message (Channel = your channel tag, Message = your payload). Message is a wildcard pin - it adopts whatever struct you connect, so plug in the Make node for your payload struct and the pin types itself. Listeners must ask for that same struct.

2. Listen

Register a listener for the channel. In Blueprint use the async Listen for Crimson Messages node (UCrimsonAsyncAction_ListenForMessage). In C++ the member-function overload is automatically weak-object-safe. Choose ExactMatch (this channel only) or PartialMatch (this channel and any child).

cpp
// Member-function overload - safe if 'this' dies before the message arrives.
ListenerHandle = UCrimsonMessageSubsystem::Get(this).RegisterListener(
Tag_Event_Damage, this, &UMyComp::OnDamage);
void UMyComp::OnDamage(FGameplayTag Channel, const FMyDamageMessage& Msg)
{
// react to Msg.Amount
}

3. Stop listening

cpp
ListenerHandle.Unregister();
// or: UCrimsonMessageSubsystem::Get(this).UnregisterListener(ListenerHandle);
Verify
Broadcast once and confirm the listener fires; unregister and confirm it stops. PartialMatch listeners on A also receive broadcasts on A.B.
Messages are not replicated
The bus is local to one game instance. To notify remote machines, broadcast on each from a replicated event (RPC / RepNotify) - the subsystem does not cross the network.

4. Forward another system's delegate

Crimson plugins do not broadcast on the bus themselves; each exposes a native delegate with the signature (FGameplayTag Channel, const FPayload&) plus a Blueprint event. To put those events on the bus, bind the delegate and re-broadcast.

Bind the component's event (Assign or Bind Event on the component) and call Broadcast Message with the event's channel and payload.

See also

  • API Reference - UCrimsonMessageSubsystem, ECrimsonMessageMatch