NEW v4.0! [Guide and Resources] How to MASSIVELY improve performance in GDevelop with Object Culling! Making any Project Run Smoothly!

Bro u really understand chatgpt

1 Like

Ahh i get you now!!

Instead of selecting the Layer and having to have a bunch of different options, i can create a check the same way we exclude objects.

We create a group where objects inside will be culled no matter the layer.

That should be easy to add, ill work on that soon!

yes, I donā€™t know if that was already the caseā€¦ Itā€™s an extra option, just to refine the deletion of objects, an extra sort that would be done by the layer or layers concerned.
In some cases, you could place objects to be deleted by putting them all on a different layer instead of creating a group of objects.
Why would you do this? Because you can change the object layer during the game. So an object can have an instance transferred to another layer, e.g. ā€œdeleted objectsā€. This allows you to filter and give additional possibilities.
In the conditions we would then have ā€œthe buffer zoneā€, the object group and the layer.

The thing is, off the top of my head i cant think of how to integrate layers in that way, where you can just pick which ones without creating a bunch of fields, id have to really think about it.

What i can do which would give you exact same result, is filter trough a simple Boolean.

We already have that system in place with the Excluded Objects checking if a boolean is set to trueā€¦ ao all i have to do is crack it open and make all objects on all layers be able to be culled.

Then the objects you dont want to be culled you put in a group to be Excluded.

If you change your mind and want that object to be deleted mid game, you can simply set their Excluded boolean to False and they will be culled.

If you set it to true mid game, they will be excluded again.

That i can possibly do easily and give it to you in an hour or so, after im done with what im doing right now

Thereā€™s no hurry, itā€™s just to move the project forward so that it can be used by as many people as possible.
Thank you for your work.

1 Like

Ahh i thought you needed it for something, ill think it over then on how to implement a Layer Filter for more options.

Heres the download link to the Version with Save States already set up and ready to use!

1 Like

Cullbuffer defines a zone around the camera, a thickness?

1 Like

Yes.

CullBuffer at 0 is exactly the size of the Camera, any object off camera will be culled.

If you put a negative number, like -100, now it will cull objects 100 pixels inside the camera, youll see objects actually being culled in real time as you walk around.

I recommend setting it up to around 100 to 300.

If you make it 0 for example, youll see still see objects being culled on the edge as you move, and the faster you move the more youll see it, thats because to make it better for performance, i added a limit to how many objects can get culled at once, so having a little breathing room on your buffer is good :slight_smile:

Perfect ! :wink:
So also when it recreates the objectsā€¦
ā€œif (objectLayer !== ā€œā€) continue;ā€ between the quotes you can put another layer or a variable to choose the layer? Empty is the base layer, right?

1 Like

If im not mistaken ā€œā€ means Base Layer, for example, when you choose a camera in GDevelop with an expression, like CameraCenterPosition(ā€œā€, 0), that means Base Layer and Camera 0, if you do CameraCenterPosition(YourLayer, 0) that selects the layers called YourLayer

You can mod the script and it should work, but it will should also only be able to select one layer at a time, so i wouldnt change that.

The mod needs to be to have target objects depending on their layer, not target the layer itself

Alsoā€¦ Did you run it trough a translator or something? Why is it French? :slight_smile:

1 Like

Yes, I ran the text through a translator, Iā€™m French, I understand a bit of the code but when in doubt I translate the comments anyway :wink:
Hereā€™s the Layer option, CAUTION I havenā€™t checked how it works. The option applies to all layers by default. To apply only to one layer, simply enter the name in the ā€œCullingLayerā€ variable instead of ā€œApply to Allā€.

Dont just throw code around, test that it does what you want and then post it, i run stuff non stop and test as much as i can, i never just make something and then share it without testing, because 99% of the time it needs adjusting

Youā€™re right, Iā€™m going to test it. When I tried it, I noticed that the camera didnā€™t move, so I couldnā€™t move it to test the codeā€¦
You had to send objects outside the zone, I wanted to move the camera with the zone.

  • While the object is culled, you can still reference its data, for example, you can still use events like ā€œat Object.X() and Object.Y()ā€ even while they are deleted

This was a lie it seems, i should of tested this better, it dosent work like thisā€¦

I could make it so that we can access this data trough variables by storing the information in variables that we can then call to use in this mannerā€¦

But im not too sure on performance dips and thats the whole point of this, its to increase performance, if we start working against the performance gains then theres no point to using this.

So for now im not adding this feature in untill i can properly test how to make it work in a simple and efficient way.

I donā€™t think you understood my message. It has nothing to do with the layer code I want to test.
The problem is that when your event is activated the camera canā€™t move!
When I deactivate it, the problem is solved, I can move it in all directions with the keyboard keys.
In your code thereā€™s a part that blocks the camera.

My previous post wasent a reply to you, i was just stating something about the script.

Also, regarding this locking camera thing, my script does nothing like that, i dont think you know how to work with layers and camerasā€¦

I just tested it, i created an object in a different layer, set the camera to follow it, and it works just fineā€¦

If you make a Player in a different layer, setting the camera to follow it and then wondering why the other layers arent moving its because each layer has multiple cameras, if you want multiple layers to follow the same object, then you need to create events that tell the different cameras in different layers to follow the same object.

Hi, I canā€™t do it, thereā€™s always a problem with the layer or the camera.

Dont worry, when i have the time ill add in a layer select

3 Likes

Hey, this is awesome, I wish I would have seen this post sooner. Thank you so much. I was looking through it and trying to figure out how to target multiple layers for culling, is this possible yet?

1 Like