How should I structure the Events code for smooth performance?

Having 80 conditions going on every tick is just too much

I want to make a bigger game, so how should I structure my coding Events in order to achieve a smoother performance?

Has any of you ever made a bigger game in this Engine?

Thanks in advance!

1 Like

How big is big? :grimacing:
I haven’t noticed any issues related to the number of conditions, the number and size of object instances is the main performance issue for me. You need to destroy your instances when they’re not used anymore, and to not create more instances than necessary.

I’ve found using object or scene timers to have certain bits of code run at intervals rather than every tick have helped performance for me. I run gdevelop on an old laptop and I need to squeeze every bit of performance out of my games to run them smoothly.

for example, I had an object with pathfinding enabled to follow the player. One object and this was fine, but adding more lagged the game.

Originally, the pathfinding object took the player position, and the target point for the pathfinding behaviour was updated every tick. It caused performance issues for more than one pathfinding object.

I got around it by having the player set it’s current position in 2 variables for x and y position, and set a timer so the code would only run once a second instead of every tick.

I did the same for the pathfinding objects, updating their target position every 1 second instead of every tick and the performance improved dramatically.

Also, if you have items that are created/destroyed, I set a condition to check whether the object exists before doing any further checks, so if you have an object that has a number of conditions, I would only have them run if the object actually exists, so I would set a condition to see if the number of objects is greater than 0, and set all relevant conditions as sub events.

Hope this helps.


Your pathfinder approach seems like a great idea.

I’ve always thought of Timers as performance consumers, and used them with caution.

But your way of utilizing them makes absolute sense performance wise.

1 Like

Nothing too fancy, just a polished rpg-style platformer.

This is a gameplay sample I’ve made to test some effects I’ve created:

*This gif is lagging due to recording issue, the game sample actually runs smoothly for now.
*Also the ground is shaking due to the rock impacts, I just increased the frequency of rocks to test performance.

I plan to have the same amount of effects on the actual game with also:
+Better Enemy AI
+Different Characters
+Different Player skills
+Different Enemies with unique AI
+Level up system

Do you think this type of game is feasible with this engine?