I am trying to better understand handling of chunks. So, thinking through it if I wanted to chunk my 2D world, how would I access it for loading?

I was thinking having each chunk have a var string for itself, and also hold the string code for every chunk connected. These codes as keys would be stored in a global dictionary with the file load path connected to them. I would then just check which chunk the character was in and then load all needed chunks surrounding, and free all other chunks. Am I thinking about this wrong?

  • xyz replied to this.
  • xRegnarokx Sounds good. You may even not need any special data. Simply use file naming convention that includes chunk's coordinate e.g.: chunk_01_03.tscn. The filename and the chunk position can be deduced from player's position.

    xRegnarokx Sounds good. You may even not need any special data. Simply use file naming convention that includes chunk's coordinate e.g.: chunk_01_03.tscn. The filename and the chunk position can be deduced from player's position.

      xyz hey thanks that would be helpful and eliminate storing tons of chunks in a dictionary and having to search it each time. I could just load the chunk + or - the chunk number. Since I'll know the size of the chunk and the starting position I can create code to calculate chunk position.