Event Dispatchers

Choose your OS:

When an Event Dispatcher is called, any Blueprints that implement and have Events bound to the Event Dispatcher will also execute when the Event Dispatcher is called. In other words, whenever the Event Dispatcher is called, any Events that are bound to it are also called allowing you to execute multiple Events at once from a single source.

This page will show you how to set up an Event Dispatcher and Bind an Event to the Event Dispatcher.

For this example we will allow the player to press a key which will cause a fire particle effect to spawn inside of a bush.

For this guide we are using the Blueprint Third Person template with Starter Content enabled.

  1. In the Content Browser, under the Content/ThirdPersonBP/Blueprints folder, open the ThirdPersonCharacter Blueprint.

    EventD_1.png

  2. Under the My Blueprint window, click the Add Event Dispatcher button and name it StartFire.

    EventD_2.png

  3. Right-click in the graph window and add an F Key Event.

  4. Drag the StartFire Event Dispatcher into the graph and select Call.

    EventD_3.png

  5. Connect the F Key Event to the Call StartFire Event Dispatcher.

    EventD_4.png

    Whenever the F key is pressed, any Blueprints that have an Event bound to this Event Dispatcher will also be executed.

  6. Compile and Save then close the Blueprint.

  7. In the Content Browser under Content/StarterContent/Props, drag the SM_Bush into the level.

    EventD_5.png

  8. From the Main Toolbar, click the Blueprints button then select Open Level Blueprint.

    EventD_6.png

  9. Right-click inside the graph and select the Create a Reference to SM_Bush node.

    EventD_7.png

    Here we are getting a reference to the SM_Bush inside our level.

    Don't see the node listed above? Select the SM_Bush inside your level then try again.

  10. Right-click in the graph and add an Event Begin Play and Get Player Character node.

  11. Off the Get Player Character node, search for and add the Cast To ThirdPersonCharacter node.

    EventD_8.png

    This will allow us to access the Events, Functions, Variables or Properties inside the ThirdPersonCharacter Blueprint.

    Please see the Casting in Blueprints documentation for more information regarding Blueprint Cast Nodes.

  12. Off the As Third Person Character pin, search for and use the Assign Start Fire node.

    EventD_9.png

    This will create two new nodes, a Bind Event node and a Custom Event. Whenever the Event Dispatcher is called inside our Character Blueprint, since we are binding that event, the Custom Event and anything connected to it will also be executed. Any Blueprints that have Events bound to the Event Dispatcher will also be executed.

  13. Off the Custom Event, add a Spawn Actor from Class node (with Class set to Blueprint_Effect_Fire).

  14. Drag off the SM_Bush to Get Actor Transform and use that as the Spawn Transform for the Spawn Actor node.

    EventD_10.png

    Once all nodes are connected, your graph should look similar to above.

  15. Click Compile, close the Level Blueprint, then click Play to play in the editor.

    EventD_11.png

    When you press the F key, the fire effect will spawn inside the bush.

For more information on working with Event Dispatcher and sample use cases, refer to the Related Topics below.

Tags