UGantryAsyncAction_ListenForMessages
Listen For Messages: a Blueprint node that hears every message sent on a channel, until you cancel it or the object that started it is destroyed.
For example, a scoreboard widget shows each goal:
- In the widget's Construct event, add Listen For Messages. Set Channel to
MyGame.Message.GoalScoredand Payload Type to yourS_GoalScoredstruct. - From On Message Received, call Get Payload on the Async Action pin. Connect a variable of type
S_GoalScoredto it. - When Get Payload returns true, the variable holds the message: update the scoreboard.
On Message Received fires once per message, with the channel it was sent on. With Match set to Partial, the node also hears every channel under Channel, and the Channel pin says which one.
To stop listening early, call Cancel on the Async Action. Messages are sent with Broadcast Message on the Gantry Message Subsystem (UGantryMessageSubsystem).
- Inherits
UCancellableAsyncAction
Properties
| Property | Type | Default | Description |
|---|---|---|---|
OnMessageReceived | FGantryOnMessageReceived | () | Fires once for each message heard, with the channel it was sent on. Read it with Get Payload. |
PayloadType | TObjectPtr<UScriptStruct> | None |
Functions
GetPayload
Copies the message being received into a struct variable.
Works only inside On Message Received.
| Pin | Type | Direction | Description |
|---|---|---|---|
OutPayload | int32 | out | A variable of the message's struct type, or of a parent struct. Filled in on success. |
| Return Value | bool | out | False outside On Message Received, or when the message is not of that type. |
ListenForMessages
Listens for messages on a channel until cancelled or until the listening object is destroyed.
| Pin | Type | Direction | Description |
|---|---|---|---|
WorldContextObject | UObject* | in | The object listening; the listener ends with it. |
Channel | FGameplayTag | in | The channel, any gameplay tag. |
PayloadType | UScriptStruct* | in | The struct expected. Empty takes any struct, and Get Payload then succeeds only when given the type actually sent. |
Match = Exact | EGantryTagMatch | in | Exact, or Partial for the channel and every channel under it. |
| Return Value | UGantryAsyncAction_ListenForMessages* | out | The node, to cancel it. |
C++
Public C++ members that Blueprint does not see.
DECLARE_FUNCTION
Get Payload's custom thunk: reads the struct the Blueprint passed in place of OutPayload.
Activate
virtual void
Registers the listener.
SetReadyToDestroy
virtual void
Removes the listener.