How to create a chunk in 2D and implement its methods

Godot Version 4.2.2


Hi everyone, I want to create a world in 2D consisting of chunks.

So the structure is as follows:

World - consists of 16x16 chunks.
Chunk - consists of 32x32 cells.
Cell - stores information and state.

I have made some sort of realization, but except for the cell I am not satisfied with anything and I would like more information on this topic, because on the Internet there is almost none (or I did not search well).

By the way, I’ve seen implementations on youtube, but they don’t work for me (just don’t work, don’t delve into it).

I also want to add that I want to make on the basis of this project game similar to Mindustry on the interaction with the game world, that is, the ability to put and break individual cells, to set the construction (of cells) the size of more than 1x1. Customize individual cells and constructions collision.

Thanks for the future.

This would be the most useful information you could provide, what have you tried and what did not work.

It’s impossible to know what you want out of “chunk” system, so far you have described an array of cells.

class Cell:
    var id: int
    var health: int

class Chunk:
   var cells: Array[Cell]

class World:
    var chunks: Array[Chunk]

Is this what you are looking for?