I'm trying to implement a virtually infinite universe in which a player can roam around in space. I've separated it into sectors, 9 of which are always active around the player, and each sector is 3x the display area (which is 800x800). (Each sector contains nine 800x800 cells, but I'm yet to see whether they're going to be of any use.)
I successfully made it so new sectors are created as the player travels, while keeping only the 9 around him active, but I'm being unable to "pause" the stuff in the sectors that are outside that 3x3 area. I have 1 dummy asteroid (RigidBody2D) per cell for testing purposes, and as I move away and see sectors being "deactivated" the asteroids keep moving and rotating. I tried set_sleeping() and remove_child(), but didn't work.
I'm using a Polygon2D as a sector background and setting its alpha lower/higher to visualize this (I shrunk the cells to 50x50 for testing as well):
The problem really is that the more I travel away the lower the frame rates will drop. I don't yet know how to save them to a file, so I was wondering if there's a way to actually "pause" everything in them in the meanwhile.
Thanks in advance.
(Also open to suggestions on whether what I'm doing is sensible: currently using one array for all sectors (each sector contains an array for its cells). Could potentially further divide the universe into bigger chunks or get rid of the cells or something.)