The Event Tick node in Unreal Engine tends to be a subject of controversy. It’s simple to use but difficult to master.
This is mostly due to the fact that this event node is activated at every frame of your game. I’m sure you can understand the tremendous impact it can have on performance when calling an event 30, 60 or 120 times per second.
So, it’s usually a good idea to avoid using it if you have another choice!
In any case, there will be times when you will have no choice but to use it.
So let’s find out more about Event Tick!
What is a Tick in Unreal Engine?
If you’re unfamiliar with the word ‘Ticking‘, it means running a piece of code or a Blueprint script that is executed once in every frame.
So, for example, if your Unreal Engine project runs at 60 frames per second, it will tick 60 times per second. It will tick 30 times per second at 30 FPS, and so forth.
However, this also means that if your game’s frames per second (FPS) decrease, the Event Tick’s frequency will decrease as well. This can lead to inconsistencies in gameplay.
If you want to learn more about identifying the frame rate of your project, I recommend reading our blog post about showing FPS in Unreal Engine.
How to Properly use Event Tick?
Use Delta Seconds
The time between Event executions is called Delta Seconds.
Delta Seconds returns a float value in seconds since the last time the event was executed.
That’s why we use Delta Seconds to optimize and make sure everything stays at the same speed, no matter the frame rate.
This helps avoid frame rate inconsistencies, so everyone has the same experience, whether their frame rate is high or low. Delta Seconds keeps things running consistently, no matter what someone’s frame rate is.
Tip 1: To use the Delta Seconds value elsewhere in your code, right-click on the output pin and select ‘Promote to Variable‘. You can also call the Blueprint Node ‘Get World Delta Seconds‘ to get the same float value.
Tip 2: Connect a Sequence node to the Event Tick to be able to execute more nodes.
Actor Tick Settings
Make sure you have ‘Class Defaults’ selected and disable ‘Start With Tick Enabled‘ inside your Blueprints if you are not going to use any tick. This will prevent Unreal Engine from trying to calculate any tick inside the Blueprint.
You can also set up the Tick Interval in seconds. For example, set it to 1 (one second) or 0.1 to make it more performant.
Using the following Blueprint nodes, you may also access these choices:
- Set Actor Tick Enabled: Enable and disables Tick in Blueprints, really useful to activate or deactivate tick during gameplay.
- Set Actor Tick Interval: Sets the tick interval of this actor’s primary tick function. Will not enable a disabled tick function. Takes effect on next tick.
- Is Actor Tick Enabled: Use this node for conditions as it has a Boolean output. It returns whether this actor has tick enabled or not.
- Set Component Tick Enabled: The same as the previous options but applied to components instead of the whole Blueprint Actor.
- Set Component Tick Interval: The same as actor interval but applied to components instead of the whole Blueprint Actor.
- Is Component Tick Enabled: It returns whether this component has tick enabled or not.
What can I Use Instead of Event Tick?
- Custom Events: Right click inside a Blueprint and select “Add Custom Event…”
- SetTimerByEvent or SetTimerByFunction.
- Timelines: Timelines work based on seconds, not frames, and they can be looped.
- Create a loop using BeginPlay + Delay to avoid using Event Tick.
- Do Once: It will call Event Tick but it won’t execute the complete code until the Do Once has reset.
- Create an Editor Tick in Unreal Engine.
- When dealing with character movement in your code, simply check to see if the character is moving or if the movement key or stick is being pressed. When it comes to specific events, such as monitoring health, only check the total health when it’s going up or down, rather than checking it every frame.
- Set conditions using the Branch node. Be creative!
- If you are using Unreal Engine 4, you can convert the code to C++ using Blueprint Nativization to make it more performant. However, this option was removed in Unreal Engine 5.
What Should be Avoided when using Event Tick?
In general, avoid connecting high-performance nodes to the Event Tick.
Here are some examples:
- Get Actor of Class: Find the first Actor in the world of the specified class. This node even includes a warning message “This is a slow operation, use with caution e.g. do not use every frame”.
- Get All Actors of Class: The same as before, but it finds all actors. For example, if you’re making a game and you have 250 enemy characters, and you use “Get All Actors of Class” in every frame, the game will have to constantly check all 250 characters to see if they match the criteria. This can slow down the game and make it run less smoothly.
- Cast To: Use it with Event BeginPlay, not with Event Tick.
- For Loop: Avoiding loops connected to Event Ticks in general is a good idea.
- Delay: The solutions explained before, like Timers and Timelines, are more efficient.
Unreal Engine Roadmap
Next Lesson:
Previous Lesson: