Using ''Trigger Once'' to Reduce CPU Usage


I understand that Trigger Once is typically used to ensure that an event only happens once when its conditions are true. However, I am wondering if it would be beneficial to use Trigger Once even in situations where it’s not strictly necessary, with the aim of reducing CPU usage.

Thank you in advance for your help!

Using it when unnecessary will decrease performance, not increase it.

1 Like

Hi Per,

Thank you for your response. I initially thought that using “Trigger Once” unnecessarily might help in reducing CPU usage by preventing the repeated execution of events.

Whether or not you use a trigger once, GDevelop will still check if the conditions of the event are true, it will only ruin performance if you use too many actions (some actions will use up more gpu than others). If you really want to save performance, a trick I use is making a condition that checks if values of something arent equal to the preferred values of actions. Making where gdevelop doesnt do unnecessary actions.

1 Like

Thank you for the insights!

Hello @PiercingGames and @per,

I read in another thread that using “Do Once” is beneficial for optimization. are “Do Once” and “Trigger Once” the same?

Trigger once triggers the event only once when the conditions are met

1 Like

Hi, just wanted to let you know that whenever you see events with “Do…”, they are actually from an older version of Gdevelop (Gdevelop 4) - the thread you have linked is from 2017. Things may be very different now. It is possible that ‘Do once’ and ‘Trigger once’ are the same conditions, but the way they work could be very different.


Also, something I figured out today is that an event is being checked until it finds a condition that isn’t true, so if you put an At the beginning of the scene at the bottom, you are potentially ruining the performance of your game.


PiercingGames, can you explain how you came to that conclusion?

1 Like

This is true just due to how game logic works in GD5.

Every event is processed every frame, from the top of the event sheet to the bottom. Within each event, every condition is processed from the top of the event to the bottom, or until it reaches a false condition. If evaluated as true, every action is processed from the top to the bottom.

If you have an event with a bunch of consitions, including “at the beginning of the scene” at the bottom (or not at the top), and it isn’t the first frame of the scene, every other condition above it has to be evaluated first before it reaches the at the beginning of the scene condition, potentially impacting performance.


I was checking the debugger console log (EDIT: I mean performance profiler), and I saw that a bunch of events that had At the beginning of the scene were still being checked (it used probably about 6 ms with about 8 events, that were just checking if a file or directory exists). But then when I put the At the beginning of the scene at the top, it barely used anything.


Condition order in an event is very important. When possible, it’s best to order the conditions from the ones that require the least processing time to the most. That way if the lesser one is false the higher one doesn’t get processed or tested.

Mouse is pressed
Cursor is on object

It’s easier to check if the mouse is pressed than to check if the cursor is in say 100 objects. If the conditions were reversed then on each frame, it would test for the cursor whether the mouse is pressed or not.

You can’t always do it. Sometimes one condition might rely on a previous condition.

1 Like

So, for example, in a loading scenario where the conditions are always met (as in this example), should I use Trigger Once to ensure that the loading process is triggered only once, to avoid unnecessary repetition?

Well it would depend on your sub-events

1 Like

Yes and no. A trigger once would prevent the actions from be triggered again but the conditions would still be evaluated on every future frame. Should the storage be deleted, it would clear the trigger once. If the storage was saved again. It would trigger the action and create another trigger once.

Storage events use more resources. So, interaction with it should be kept to a minimum. There should always be another less demanding condition before them.

If the storage only needs to be checked once. I would use at the beginning as the first condition of an event and place any other conditions below it or in a sub event.

An at the beginning only test the other conditions once during the 1st frame. No matter what the other conditions are or even if it’s the only condition, it will only check the other conditions once and trigger if they are all true.

In future frames the at the beginning is the only condition that gets checked and on future frames it will always be false and any other conditions or actions or sub events will be completely ignored.

1 Like

If there is no condition associated with an action, for example, showing an object, will GDevelop repeat this action multiple times even if the object is already shown? Or will it execute the action only once?

It’ll execute the event every frame

1 Like