Optimization of a large project

I’ve been working on a huge platformer project with more than twenty scenes and hundreds of different objects. I’m having problems with optimization recently. In my latest two scenes the game lags a lot. Also according to my tests it is mainly caused by the decoration in the scenes, not the events. Do you guys have any advices? I can’t believe that a 2D platformer game takes more than 1gb in the RAM.

A bit more context is needed before folks can give suggestions:

What is the largest sprite size? What is the smallest? (Keep in mind that even Hollow Knight’s largest moving asset is only 400x400 pixels (with most much smaller), most of the backgrounds are pieced together from separate parts, etc)

How are you determining that the decoration is causing the issues? Did you run the profiler in the debug preview to see what it is showing the most render time?

You could try putting all your decorations on a “Decoration” layer, and then delete all objects on that layer when the scene initializes to see if it actually makes a difference.
GDevelop has some built in culling, so objects that are far away from the camera I believe shouldn’t contribute too much towards performance.

Thanks! I will try it today.

Well, I don’t know if this sprite is too big, but, the canvas of the main character is 300*300, of course the actual sprite is much smaller.

Do you have many effects in the scene? Extensions?

I put all different pieces of the scene’s decoration in a few objects, and switch their animations to show different more pieces. Is this helpful to the performance?

No. I tried to remove the background blur in the scenes but it doesn’t do much. I don’t even have a lighting layer. (Well, if I have, maybe the game would lag more.)

Do you have many repeat-for-each-object events?

What is the size of your assets on disk? Do you have sound files? Are they large?

For each enemy, there are repeat-for-each-object events. Some of the decoration like lamps in the scene also have repeat-for-each-object events.

The size of assets is around 219 mb. The sound files add up to 30 mb. Also there are some fonts in the project.

You mentioned earlier the decorations were taking up a fair chunk of the CPU. Do you need the repeats on the decorations? Only use the repeats if the action is unique for each object - i.e. the action on one of the objects will differ to that of another.

If you could screen snip the decotration repeat events (and the code around it), we might be able to spot some improvements.

Can you also screen snip the enemy repeat events?

The ‘lamps’ part doesn’t use the lighting objects in gdevelop.

The repeat-for-each-object event is definetly required for the enemy. Also for some reason, a serious of problems could be cause if I use trigger once in enemy’s actions like attacking or switching animation.

Are those your only repeat blocks for the decorations?

How many decorations in the scene? And roughly how many SmartEnemy objects are there in a scene?

From your first post yousaid

How did you test test it to come to that conclusion? Did you run the game in debug mode, with the debugger and performance profiler on?

When I was starting a new scene, after I built the basic blocks of platforms I added the panel sprites and tile sprites of walls and floors. Before I added those the game was fluent with some of the ‘smart enemy’ activated but after I added them the game started to lag. This became more obvious after I added the other decorations. Well, I didn’t use the debugger(I have no idea how to check the performance by using that).

Ok, that seems a reasonable conlusion. Are there any other decoration events? Do you create any dynamically, or are thay all placed in the scene in the editor?

Only the ‘light’ is created dynamically through the events(actually it is just a sprite, not a light object). There is no interaction with the floor or the wall in the events.

If you run the scene and press ctrl+shift+i and then click on the console tab, are there any error or red messages?