New answers tagged memory-efficiency
Do what the 1 million developers before you did and build a chunking mechanism for "paging" portions of your world in and out of your scene on demand. A quick search on here for "paging" or "chunks" should give you all you need. I think this has been pretty well covered here in the past.
Your idea is correct, only render and update entities near the player for better performance. To do this in a efficient manner, you will need some sort of spatial partition to know what is near the camera. You definitely don't want to loop through all the entities on your map. One of the most efficient ways to use is a hash table, also known as a grid. But ...
If I understood the problem correctly it's not that hard to solve. You track the position of every entities and update/render them only if they are inside or near the view field. The other way round you can of course destroy them if they are outside the view frustum (if you want that). Just loop through the container and check x and y coordinates and ...
Top 50 recent answers are included