Page Info
Engine Version:


Choose your OS:

Function Declaration

Functions can exist in two basic forms: a regular C++ function or a UFunction. Both C++ functions and UFunctions are declared in the .h class header file. C++ functions are declared using the standard C++ syntax for declaring a function. UFunctions use a specialized syntax that allows additional information about the function to be specified in the declaration through the use of Function Specifiers .

UFUNCTION([specifier, specifier, ...], [meta(key=value, key=value, ...)])
ReturnType FunctionName([Parameter, Parameter, ...])

UFunctions behave the same as C++ functions in that they have a C++ implementation, can be called from within C++ code, and can contain calls to other C++ functions or UFunctions within their function bodies. UFunctions differ in a few areas, however. For instance, they can be called or overridden from within the Blueprint Visual Scripting system. Any UFunction declared using the BlueprintCallable, BlueprintImplementableEvent, or BlueprintPure specifiers (see Function Specifiers below for more details) will be exposed to Blueprints. UFunctions can also be assigned as delegates within the default properties of a class. This technique is commonly used to bind input actions or axes to functions in Input classes. UFunctions are also used as replication callbacks; meaning the UFunction will be called when the variable it is associated with changes and is replicated across the network. UFunctions are also the only type of function that can be declared as an exec function allowing them to be called by the player from the in-game console during play.

Function Specifiers

When declaring functions, specifiers can be added to the declaration to control how the function behaves with various aspects of the engine and editor.

Metadata Specifiers

The usage of metadata specifiers differs between regular classes, functions, and interfaces.

Functions can use the following metatag specifiers:

Function Parameter Specifiers


Declares the parameter as being passed by reference allowing it to be modified by the function.


With the optional keyword, you can make certain function parameters optional, as a convenience to the caller. The values for optional parameters which the caller does not specify depend on the function. For example, the SpawnActor function takes an optional location and rotation, which default to the location and rotation of the spawning Actor's root component. The default value of optional arguments can be specified by adding = [value]. For example: function myFunc(optional int x = -1). In most cases, the default value for the type of variable, or zero (e.g. 0, false, "", none), is used when no values is passed to an optional parameter.

Function Implementations

Functions declared in the class header file are given definitions in the class source file.


Delegates allow you to call member functions on C++ objects in a generic, yet type-safe way. Using delegates, you can dynamically bind to a member function of an arbitrary object, then call functions on the object, even if the caller does not know the object's type.

It is perfectly safe to copy delegate objects. Delegates can be passed around by value but this is generally not recommended since they do have to allocate memory on the heap. You should always pass delegates by reference when possible.

Both single-cast and multi-cast delegates are supported, as well as "dynamic" delegates which can be safely serialized to disk.

See the Delegates page for reference and usage information.


Timers schedule actions to be performed after a delay, or at a over a period of time. For example, you may want to make the player invulnerable after obtaining a power-up item, and then restore vulnerability after 10 seconds. Or, you may want to apply damage once per second while the player moves through a room filled with toxic gas. Each of these can be achieved through the use of timers.

See the Gameplay Timers page for reference and usage information.