Binding Events

There is a Bind Event node that binds one Event to another Event or to an Event Dispatcher, which can be in another Blueprint. When an Event is called, all the other Events that are bound to it are also called.

As an example, let's create a child Blueprint class of Blueprint_Effect_Sparks. This new Blueprint binds an Event to the PlatformPressed Event Dispatcher of the BP_Platform Blueprint that we created in the previous example:

  1. Open the project used in the example of Event Dispatcher.
  2. Create a Blueprint, expand the All Classes menu, and search for Blueprint_Effect_Sparks, which we'll use as the parent class. Name it BP_Platform_Sparks and open it in the Blueprint Editor.
  3. In the My Blueprint panel, create a variable named BP_Platform of the BP_Platform type object reference. Check the Instance Editable attribute.
  4. Drag the BP_Platform variable from the My Blueprint panel and drop it in Event Graph. Choose the GET option to create a node.
  5. Drag from the blue pin of the BP Platform node and drop it in the graph to open Context Menu. Add the Bind Event to PlatformPressed Action.
  6. Drag from the red pin of the Bind Event node, drop it in the graph, and choose Add Custom Event.
  7. Drag the Sparks Component from the Components panel and drop it in the graph. Drag from the blue pin of the Sparks node, drop it in the graph, and choose Activate.
  8. Connect the nodes, as shown in the following screenshot, and compile BP_Platform_Sparks:

  1. Add an instance of BP_Platform_Sparks near the instance of BP_Platform that is already on the Level. On the Details panel of the Level Editor, click the drop-down menu of the BP_Platform variable and select one instance.
  2. Click the Play button of the Level Editor to test the Level. Move your character to the location of BP_Platform. When your character overlaps it, the PlatformPressed Event Dispatcher is triggered, and the Custom Event of BP_Platform_Sparks is executed, activating the sparks.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset