Page Info
Skill Level:
Engine Version:

Using Custom Events and Structs

Choose your OS:

The Event Track can be used to call Custom Events that can execute Blueprint Scripts inside of multiple Blueprints. When 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. When using the Event Track and calling a Custom Event, you can also pass through your own Custom Structs, which can be used to update the variables contained therein. This can be useful in situations where you want to update other variables during the playback of a Level Sequence.

In this example, we use the Event Track to call an Event with a Custom Struct that is used to move an object in the Level Blueprint and turn off/on a Point Light in another Blueprint.



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

  1. From the Content Browser under the Content/StarterContent/Shapes folder, drag the Shape_Cube mesh into the Level.


    Position the mesh anywhere inside of the Level.

  2. In the Details panel for the mesh, set it to Movable.


    This will enable us to move the mesh during gameplay.

  3. Click the Add New button in the Content Browser then, under Blueprints, select the Structure option.


  4. Enter the name MyStruct, then open the asset and add a Vector variable called MoveCube.


    The naming of your variables is important here because these names will need to be used when you want to reference them later.

  5. Add a new Level Sequence called Master to the Level, then inside Sequencer, add an Event Track.


  6. Move the timeline to frame 5 and add a key, then right-click the key and name the event LiftCube. Now, assign MyStruct and set the Z value to 100.


    When we get to this keyframe in our sequence, we are going to move our mesh up by 100 units along the Z-axis.

  7. Move the timeline to frame 10 and press the ] key to end the sequence at frame 10.


  8. Select the mesh that you added in the Level (along with the Level Sequence), then click the Blueprints button from the toolbar and select Open Level Blueprint.


  9. In the Level Blueprint, right-click and search for Reference, then select Create References to 2 selected Actors.


  10. Right-click in the graph and add a 1 Keyboard Event, then drag off your Master Level Sequence, searching for and adding the Set Playback Position node.


    This will be used to reset your sequence whenever you start to play it before issuing a play function call.

  11. Drag off the Sequence Player node being added, and use the Play node, connecting as shown below.


  12. Right-click in the graph and create a Custom Event called LiftCube.


    Your Custom Event name must be the same name that is specified under Event Name for your key in Sequencer (or it will not get called).

  13. In the Details panel for the Custom Event, click the + button to add an input, naming it MoveCube with the variable type of Vector.


    The event will not be called if the following conditions aren't met:

    • The Input names must be the same names that are used in your Struct.

    • The number of inputs must match the number of variables defined in your custom struct.

    For example, if your struct has 2 variables in it, your Custom Event must have 2 inputs with the correct variable names and types.

  14. Drag off your mesh reference, search for and use the AddActorLocalOffset node.


  15. Connect the MoveCube vector pin to the Delta Location pin, and the LiftCube executable pin to the AddActorLocalOffset node as shown below.


    If you play in the Editor, each time you press the 1 key, the cube will move up along the Z-axis.

    We are using the Level Blueprint to execute our Custom Event, but there may be examples when you are using and want to effect a different Blueprint or multiple Blueprints.

  16. From the Content Browser under Content/StarterContent/Blueprints, drag the Bluperint_CeilingLight Blueprint into the Level.


  17. In the Details panel for the Master Level Sequence, expand the additional options under General and add the Blueprint_CeilingLight as an Additional Event Reciever.


  18. Open the Blueprint_CeilingLight Blueprint and add the following script.


    • Create the Custom Event called LiftCube that corresponeds to the Event in Sequencer.

    • Use a Flip Flop node to Set Intesnity of the Point Light to 0 (off) or 5000 (on).

    This will toggle between turning the light off or on whenever the Master Level Sequence is played.

    Notice that although we are not using the Custom Struct MoveCube in this Blueprint, in order for the Event to get called, you will still need to add it.

  19. Play in the Editor.

End Result

When playing in the Editor, the cube will move up along the Z-axis whenever you press the 1 key while the light toggles between on/off states.

In this example, we are calling an Event in the Level Blueprint as well as inside a Blueprint Class from Sequencer. We are not assigning a camera to view our cinematic from but instead are using Sequencer and Blueprint to perform scripted sequences. In your projects, an Event Track with a Custom Event and Custom Struct can be used to update player information during a cutscene (such as the player receiving a health increase, new weapon, or other gameplay related effects of your choosing) during your defined points within your cinematic sequences.