I have no idea how to make Arrays and Structures work… id really appreciate some help, iv been doing some reading and i cant work this out in my brain
Im trying to improve performance on my Minecraft style game by doing Object culling.
My idea is to delete objects that are off screen and recreate them if their position is almost in view.
My idea was to check if an object is out of view from the camera, then store their X Position into an Array and the same for their Y, into a different Array.
So far so good…
Then run a check if the X and Y value of the arrays are within the camera borders, if so then create the object using those values and remove the variables from the arrays…
The issue is how the heck do i check for those values inside the Arrays?
…or how do i tell GDevelop to remove those specific values it just used from the index?
Maybe im just being slow because its getting late, but i cant seem to find the expression i need to use, or maybe im just going about this all wrong…
Can someone help me understand all this? Any ideas how i can do this?
Culling is usually to avoid to iterate over everything. if you iterate over everything to do the culling, you’ll likely not see any benefit.
It’s not something that can be done with events.
Just did some testing and the results are as Davy says, its bad…
Its always better to have all objects in the scene then it is to cull them with events…
On a small scale, no culling results in about 10ms, with the culling on only one set of tiles, its 12ms, so… no dice on the culling…
On a bigger scale, the events went up to 21ms, and again, thats just checking for one tile type, if i had made it check for all types im sure the game wouldnt even load lol
Oh well, this was a fun learning experience anyways, now i know how arrays work and can probably do some cool stuff with them!