Calling Custom Events

The Event Track can be used to call Custom Events and fire off Blueprint Script inside the Level Blueprint . Once the Custom Event is called, any script attached to it will also be executed and can be used for any number of scenarios based on your needs.

In this example, we will execute an Event which will be used to activate a particle effect in the level.

Steps

For this how-to, we are using the Blueprint Third Person Template project with Starter Content enabled.

  1. From the Main Toolbar click the Cinematics button and Add Level Sequence.

    EventTrack1.png

    Choose a Save Location and give the Level Sequence a name when prompted.

  2. In Sequencer, click the Add button and select to add an Event Track.

    EventTrack2.png

  3. On the Event Track, move the Timeline Marker to 75 then click the + sign to add a key.

    EventTrack3.png

  4. Right-click on the key, then under Properties enter the name MyEvent for the Value.

    EventTrack4.png

    The name you provide here is the name you must use when creating your Custom Event that you want to call.

  5. In the Content Browser under StarterContent/Particles, drag the P_Explosion into the level.

    EventTrack5.png

  6. With the P_Explosion asset selected, in the Details panel un-check the Auto Activate option.

    EventTrack6.png

    This will ensure that the particle effect is not played upon starting the level.

  7. With the P_Explosion asset still selected, click the Blueprints button from the Toolbar and select Open Level Blueprint.

    EventTrack7.png

  8. In the Level Blueprint, Right-click and select Create a Reference to P_Explosion.

    EventTrack8.png

  9. Right-click in the graph again and search for and add a Custom Event node and name it MyEvent (the same as in Step 4).

    EventTrack9.png

    This must be the text you entered as the value in Step 4. You can press the F2 key on the node to rename it.

  10. Left-click drag off the P_Explosion node and search for and add the Activate (ParticleSystemComponent) node.

    EventTrack10.png

  11. Connect the Custom Event to the Activate node as shown below.

    EventTrack11.png

    When the event is called it will activate (turn on) the particle effect we placed in the level.

  12. In the Main Editor window from the World Outliner select your Level Sequence then in the Details enable Auto Play.

    EventTrack12.png

    When we play in the level, this Level Sequence will automatically play and trigger our effect.

  13. Click the Play button from the Main Toolbar to play in the editor.

End Result

When playing in the editor after a few seconds, the explosion will activate.

In the video above, we also illustrate that you will not see the script being executed when you click the Play button inside Sequencer. You will only be able to preview your scripted events being called from your Event Track during gameplay when the Level Sequence is played.

Tags