I’m writing a chunk loader which uses collection factories to spawn level chunks. These chunks consist of a tilemap, as well as start and end “marker” objects to position the chunks correctly. I keep a table that holds references to these newly created collections so that I can delete them later.
My chunk loader code is in a pastebin here. There are comments.
The loader starts by spawning two chunks, the first one and then the second one in order, and then placed in self.chunks
. When the first chunk passes camera_x
, what should happen is that the first chunk is deleted and a new chunk is spawned. Instead, the first chunk stays where it is and the second chunk is deleted, which causes an error when trying to spawn and reposition a new chunk.
I can’t seem to figure out why this is happening. Any ideas?
PS: If you need me to share the project I’ll need to DM it, since I’m using paid assets that can’t be shared online.