Functions
Just as Macros and Custom Events, Functions allow a set of actions that are executed in various parts of the Blueprint to be gathered in one place for easy organization and maintenance of the script.
Functions can be called from other Blueprints and allow the use of output parameters. A disadvantage is that the Functions need to be completed immediately when executed, so in the Functions is not allowed the use of Latent Actions such as Delay and Timeline.
Functions can be called from other Blueprints and allow the use of output parameters. A disadvantage is that the Functions need to be completed immediately when executed, so in the Functions is not allowed the use of Latent Actions such as Delay and Timeline.
The following example shows the creation of a function named "EnemiesLeft" that has an output parameter called "NumEnemies". This function is marked "Pure", so it will not have execution pins. Pure functions should not modify the variables of its Blueprint.
The functions allow the use of local variables that are only visible inside the function. They are very useful to assist in complex functions and do not mix with the other variables of the Blueprint.
The "EnemiesLeft" function was created on a Blueprint named "Enemy Manager" that is responsible for managing the enemies of the game. It will return the number of enemies that still exists based on the enemy class that is in the variable "Current Enemy Class".
Click to enlarge |
This image shows the function being called from another Blueprint.
Click to enlarge |
Table of Contents