What is the Delay node?
The Delay node in Unreal Engine is a simple yet powerful tool that allows you to create timed events or delays in your game’s mechanics.
You can use the Delay node to execute a set of Blueprint code after a specified number of seconds. Delays can be extremely useful for creating complex gameplay mechanics or a simple countdown timer, so they should be an essential tool in your arsenal.
However, as with any tool, the Delay node must be used with caution and consideration.
In this blog post, we’ll look more closely at the Delay node, including how it works, when to use it, and alternative methods to consider.
How to use the Delay node?
To use the delay node in Unreal Engine, you can simply connect blueprint code to the input node or an event, such as an Event BeginPlay.
Once you set the duration input to a specific time, the code that is connected to the “Completed” output pin will execute once that time has elapsed.
For example, if you set the duration to 2 seconds, the rest of the code will execute after 2 seconds.
The “Duration” input for the delay node in Unreal Engine lets you enter float values. This means you can use numbers with decimals, such as 0,2 seconds. This will help to create precise delays in your game.
Tip: If this node is triggered again while the timer is still running, the call will be ignored.
Retriggerable Delays in Unreal Engine
Now that you understand what delays are, let’s look at when you should utilize retriggerable delays.
A retriggerable delay can be triggered several times, and each time it is triggered, the delay timer will reset.
This means that if you trigger the delay before the countdown has ended, the timer will reset and the delay will start the countdown again.
I recommend that you run the example in the image below to see how the nodes work in real time. If you’ve never used the Print String or a Keyboard Event node before, click the link for more information.
In general, you should use retriggerable delays when you need to repeat an action or set of instructions with a consistent delay between repetitions. A regular delay node will suffice if you only need to delay one action.
Using Delays in Functions?
If you see a node in Unreal Engine with a clock in the corner, it means it’s a latent node.
Latent nodes can only be used in the Event Graph or Macros, not in Functions or Loops.
So, if you want to use a delay node in your Blueprint, make sure you’re using it in the Event Graph or in a Macro.
Common problems using delays in multiplayer games
Delay nodes in Unreal Engine can be problematic in online multiplayer games. In a multiplayer game, delays can cause synchronization issues between clients and the server, leading to inconsistencies and inaccuracies in gameplay.
The delay between the server and the clients in online multiplayer games can increase as the number of clients or the distance between servers increases. This means that delay nodes may need to run for longer periods of time to ensure that all clients receive the correct data. The problem is that it’s difficult to predict how long the delay will be, making it difficult to synchronize gameplay across all clients.
In addition to synchronization issues, delays can also cause performance problems in online multiplayer games. When multiple clients are executing the same delay node, it can put a strain on the server’s resources and slow down the game’s performance.
As a result, it’s generally recommended that delay nodes be avoided in online multiplayer games. Instead, game developers should use alternative methods, such as timers, like the Set Timer by Event node. These methods are more reliable and can be easily synchronized across all clients and the server, ensuring that the gameplay remains consistent and accurate for all players.
To learn more about it, I recommend watching this video.
Unreal Engine Roadmap
Next Lesson
Previous Lesson