Need tips regarding game performance

Hello guys I need some tips. So my completed but unpublished game has some problems.

After some time while playing, it lags so much its barely playable. And I have questions that need answering

  1. Does cloud-base storage and local storage has some kind of difference regarding game performance?

  2. I save my storage and timestamp every beginning of scene. Does that affect game performance?

  3. I have action timers on external events, but the timer only starts at a specific scene (timer gets deleted after the scene). Would the timer still be read even without starting the timer?

  4. I have about 100 global variables, does that affect initial loading so much that it can crash on loading screen?

These are the problems I’m facing right now. I just want to solve it so I can finally publish it. Thank you for the help

1 Like

Nothing i see here sounds like source of lag
But if the more you play the more laggy game gets

That sounds like creating objects and not deleting them

1 Like

It shouldn’t crash but players tend to move on if its taking a while. It really depends on how big the image files are and also sound files …avoid having music as wavs
why don’t you post a link to the game in the community section and get some helpful feedback. It might be more apparent what the problems are when playing it.
You can DM a link if you’d prefer that

1 Like

The only reason for accumulative lag is something increasing, like objects for example. Try using the debugger to see if a value is just constantly going up, like the number of object instances.

1 Like

To understand the reason, you should at least know what kind of game it is. If there are many physical objects, the game may become overloaded. You may also have many images.
The performance is not affected by the information you provided.

1 Like

Publish the game and give us a link so we can see it, and maybe we’ll figure out what the problem is

Hi, I use the action “Change the scene” every time i transition to the next. Don’t the objects that exist in that scene get automatically deleted from memory?

The source of lag starts after I unlock a new stage. Means new area, new enemies new background image. I kind of figured that when I use “change the scene action” all objects get deleted automatically, or does it not?

If you go from Scene A to Scene B
NOTHING from Scene A can affect Scene B

If you start game from Scene B and it lags then problem is there

So it’s not the objects from my previous scene that affects the performance. I used the debugger, and when I looked at the profiler. The highest value is 21 ms from my external events. i don’t know if thats supposed to be high but when i play in preview there are no problems. Only in my exported game.

The lag always happen when I unlock a new area. When I restart it, everything is okay again but when I defeat the boss and unlock another new area then the lag comes back

Do you delete old stuff before loading new one?

Where are you exporting the game to?

If you mean I delete objects from actions, then no since I thought if i use “change the scene” it automatically gets deleted. Right?

My game is supposed to be published in google play store

Yaeh but like you CHANGE scene
OR pause scene and go to another scene then come back to paused scene

Then in new scene do you create objects from external layout once and or do you spam it by mistake?

You could totally debug your own game by yourself by simply disabling events and checking did something change

A few other things that affect performance to consider:

Like others have suggested a huge number of objects, like bullets flying off screen that aren’t deleted. Made worse if certain object effects is on as well.

Visual Effect objects with animation that ends transparent, but isn’t deleted after animation is finished.

A large number of 2d particle emitters that exist all at the same time.

Large number of physics objects in the scene, even if they are off screen can slow things down.

If you are using lights and they are large and have a lot of objects to collide with to cast 2d shadows. If they have a lot of complex hotboxes to hit also affects

If you are using the pathfinding behavior on a lot of enemies can also deeply impact performance.

It could be the result of having a heavy behavior that I haven’t thought of and used on a lot of enemies.

Those are a few more things to check, also these are all suggestions to check for a 2D game. 3D I am not so sure on.

Hello everyone. I have discovered the source of the lag. The reason is the “For each object” event.

Since I used for each object that enemies are; for example paralyzed, an animation is changed.

Even though it has trigger once, the game still checks each instance of enemies (Even the ones not on the scene) thus the reason for the lagging when moving to the next area because of new set of enemies created. Anyway thanks for everyone helping