How to use Custom Events in Unreal Engine 4

An essential part of developing games with Unreal Engine 4 is learning Custom Events.

Custom events are used to run a set of blueprint nodes on demand.

Custom events are different from Functions as they can contain delay nodes and are created in the event graph.

In this guide we are learning how to create, setup and call custom events in Unreal Engine 4.

Creating the Custom Event

To create a custom event, right click anywhere in your actor’s event graph and write “Custom Event”.

Then click “Add Custom Event”.

Adding the custom event

Once created, name the new custom event.

It’s good practise to name your custom event based on its purpose.

Naming the newly created custom event

Your event has now been created!

For this guide we named our custom event “My Custom Event”.

Created event named "My Custom Event"

Adding Inputs

Similar to functions, custom events can have input variables attached to them.

These are used to send information to the nodes running from the custom event.

To add an input firstly click your custom event in the event graph and look to the right side of the screen.

Click the “New Parameter” button shown below to add a new variable to the inputs list.

Adding a new input to the custom event

Then change the name of the input. The left side text box is the name that will be displayed inside the custom event.

Renaming the added input variable

On the right side we can then change the input variables type.

We are changing this variable from Boolean to String. This means we can use text values in our input.

Changing the new variable to be a string
When making your own custom events you can use any of the variable types shown.

The finished custom event input should now look like this.

finished input variables for the custom event

The custom event in the event graph will now look like this.

finished custom event

Using your Custom Event

Now that are custom event is created and the input variable has been setup, we can now create a “Print String” node to display the value of “My New Input” on the screen.

This is the easiest way to test if the custom event is working correctly.

Creating a print string node to test the custom event input value.

Once the “Print String” node is created, connect the “My New Input” variable from your custom event to the In String pin on the Print String node.

Connecting the input variable to the In String value on the print string.

To run your custom event simply create a “Event BeginPlay” node, drag from the execution pin and type the name of your new custom event. In our case this is “My Custom Event”.

As your custom event is connected to an execution pin, it is now being called by the other event.

On begin play calling the new custom event.

Now that your custom event is being called by the BeginPlay event you can see the input variable.

This input variable pin can be connected to any variable with the same type.

Connecting the my custom event to the begin play node.

We can now write any text into the My New Input variable.

Writing my custom event works in the my custom event node.

Testing the Custom Event

Running the game will now show the text that we wrote in the custom event.

The custom event runs correctly and prints the text on the screen.

Conclusion

Now you have the knowledge to create and use custom events in Unreal Engine 4!

Custom events are an essential component of Unreal Engine and are especially important for multiplayer game creation using blueprints.

Below are a few links for the full custom event documentation and a guide for using custom events and other Unreal Engine 4 features to make a multiplayer damage and health system.

Click here to read the official documentation on Custom Events in Unreal Engine 4

Click here to see our guide on making a multiplayer ready damage and health system with custom events.

Be the first to comment

Leave a Reply

Your email address will not be published.


*