Do the order of conditions affect performance?

Can the order of conditions in an action affect performance? Intuition tells me they can, but I don’t know enough about the inner workings of the platform to know if this is actually true. For example:

The variable TabSpeed of Banner = 0
The timer “TabCorrection” is greater than 0.2 seconds
(with corresponding action to Reset the timer “TabCorrection”)

This way around, I presume every single frame two variables have to be tested (the variable and the timer). Put them the other way around, one variable has to be tested every 0.2 seconds (the timer). So the other way around is better? Or perhaps you’re doing something clever so that no code actually gets fired until the variable changes value, which would be very cool.

Another example:

The cursor/touch is on Valves
Touch or Left mouse button is down

This way around the game engine has to determine every frame whether the cursor is over a particular sprite regardless of whether or not the mouse button is pressed. Put them the other way around and then it doesn’t have to figure out where the cursor is in relation to this sprite if the mouse button is not pressed and in a game where the mouse button is released more often than it is pressed would be of benefit, right or wrong?

They can improve performance for one reason: object selection.
You see, the engine will filter out of the list of all instances of an object to the ones respecting all conditions. To do so it will execute the conditions in order. So if a condition removed only one object from the selected object and another 50, it would be more performant to first have the one with 50 eliminations, as then those fifty objects wouldn’t have to be checked in the condition removing 1 object.

In How exactly does "Trigger once while true" work? - #3 by arthuro555 @arthuro555 said:

GDevelop doesn’t call next conditions when a previous one was false (after all there is no point as all need to be true to execute actions).

I take that to mean that:

  • Touch or Left mouse button is down
  • The cursor/touch is on Valves

Would be more be performant since, as you said @chapter34, that wouldn’t need to be checking what objects are under the mouse cursor when the left button isn’t down.

Correct me if I’m.misunderstanding that @arthuro555

Yep, you got it :+1: