Improved Object handling by the Engine

I have no idea how the engine works, but i can tell what slows it down thanks to a lot of testing and the profiler.

The big issue with slow down is Object amount, not even the behaviors or anything like that, just the sheer fact of asking GDevelop to take into acount the existance of an object kills your performance… when used in higher amouts that is.

Finding this out trough an entire day of testing, i lowered my world generation to a 50x50 grid, of 64x64 tiles, this makes the world playable, but tiny, not to mention with large blocks.

The lowest this world goes to is 12.00ms, with no extra events, such as enemy AI, items, inventory, and so on… just the world generation.

Again, i have no idea how GDevelop works, but that should be something to deal with larger amounts of objects… and 50x50 isnt even that big.

Objects should be taken into account when the scene is loading or after their generated, then if they go off screen, they should be killed off from any calculation unless strictly asked for, like for example if you check for “Distance between objects”.

If such actions arent being asked for, then i really wish there was a way to kill off processes to anything outside of a X amount to the border of the camera.

As in, as the camera moves, its the camera thats checking whats around and then making them active off screen, this distance could be specified trough an action.

I know we can kinda do something like this, but what we have now engages every single tile, even if their on the complete oposite side of the universe, im talking about some sort of baked in culling system that only checks near objects, ignoring all the ones out of range.

Im not sure if i explained myself right :frowning:

The point is, there really needs to be something to deal with projects like this, i was so happy about working with procedural generation only to start feeling more and more constricted by performance as i work.

Its not my events, since all that i have is quite literally the world generation that gets killed off once done, my events are 0.80ms out of 12.00ms, its all coming from Objects and Render.

Is there anything im missing?

4 Likes

I know you say it isn’t the events, but I would be interested in seeing them anyway, and/or knowing more about the exact process you are using to generate a map.

In a lot of cases map generation is done all in one go and it is acceptable to hog all the CPU, as it is no different than loading a map and people won’t mind waiting a few moments in between maps. So unless you are trying to dynamically generate new terrain without slowing down gameplay, it really isn’t necessary to make it as efficient as possible.

If you do need to improve your generation time, checking distances is probably something you should avoid altogether. If you are generating a tile you already know its exact location and can easily calculate the distance from another point. My question would be, why are you even calculating a distance in the first place, and can that be avoided.

Objects should be taken into account when the scene is loading or after their generated, then if they go off screen, they should be killed off from any calculation unless strictly asked for, like for example if you check for “Distance between objects”.

Things that go off screen stop animating, but by asking for the objects within a certain distance you are strictly asking for all those calculations. Again, I’m curious about how exactly you are using this because it sounds like there may be another solution.

One thing that could improve performace would be to replace your individual tiles with a tiled sprite when possible. This can be tricky with procedural generation if you have “curves” (i.e. for cave walls) rather than just straight walls. But if you had for example a floor texture that you just want to cover the entire floor, you can use a large tiled sprite instead of many sprites, and just stick the walls on top of it.

I can show you the events, but they are basically doing nothing.

I made a “State” for the events, while its generating the world, i let it do its thing, the moment its done, then the boolean toggles to True and every single event that has anything to do with world building gets cut off.

And vice versa, so while the world is being built, things like distance checks, collision and so on are all turned off.

My events run about 0.50ms after world building.

The generation is also gated by frames, since you can only build a block per frame if your only using one spawner.

My way around this was to generate multiple spawners first and then build the world in chunks.

Anyways …the point is, its not the generating thats bothering me, its the after generating and how much latency objects take up as a whole.

When it comes to having a lot going on in your project, GDevelop falls behind other engines, thats just how it is, im not trash talking, i love GDevelop, but it has its limitations.

I can run things like Diablo 3, with a screen filled with particles, 3d models, all sorts of calculations and madness, with super high desity and detail… my pc handles it just fine

…but having some basic, bland, single color blocks on screen in my project? NOPE, fps dead… and again, its not my events, the events have no latency.

Its the object handling.

It isn’t quite fair to compare to something like D3 which is first of all a more dedicated engine, and second and more importantly it is NOT cross-platform and cannot just be played in a browser. GDevelop makes HTML5 games, not native Desktop (or console) games. And you can still have quite a lot going on, I’ve had hundreds of objects and even more particles on screen with 60fps on my work computer which can’t even update to WebGL 2 (I literally can’t play any godot games in browser because of it lol)

I have also run into performance issues that seemed ridiculous at the time, so I know how frustrating it is, but I have managed to improve my methods in some cases and get rid of those performance hogs. I’m just not sure what would be helpful for your project so if you feel like sharing I’d be happy to take a look at it, you could even send the actual project files if you feel comfortable, I’d run it on this potato and see how bad it is :stuck_out_tongue: (but I understand if you didn’t want to do that and just screenshot your events, however there’s stuff outside of events that could be relevant such as how you are using effects)

Im not saying its fair, im just saying.

It is what it is, GDevelop does HTML5 Games not “dedicated” desktop games, so what? Yes it can do less, thats the point im making its a limitation.

Im not knocking GDevelop, im simply acknowledging a limitation so that i can be adressed and worked around.

The whole point of this testing was to see the actual limits and then try to adjust or bend them, you just seem to be misunderstanding this whole thing and trying to defend something that cant really be changed unless you make the engine somehow better.

Also… hundreds of objects? Thats peanuts, im not taliing hundreds, im talking thousands and tens of thousands, possibly millions.

I wanted to see the limits on how many objects is too many for GDevelop.

I really wasn’t trying to justify one engine or another, or accuse you of anything. Just saying that I have a little bit of experience with optimization in GD and that I’m offering to look at your project to see if there’s anything I notice that could be improved. The final question in your original post is “Is there anything I’m missing?” and I’m saying in response “Maybe, but we don’t know for sure without looking at the project itself”

There is no discrete limit on how many objects is too many. It depends on multiple factors including the machine that’s running the game.