Hi, I’m thinking about the best way to represent positioning of game objects/terrain in a large 2D game world.
One idea I had is to have arrays representing positions of game objects, which would then map to the actual game coordinates with a scale factor. Like in this example image, I have an array of 144 elements (12 by 12) which holds float values, which in turn can represent objects/terrain etc. (for example the mushroom in the top left grid is positioned four cells to the left and four cells above the center cell of the array, which would represent the center of the game world. In world coordinates this object could for instance be placed with a factor of 100, at (-400, 400).
How would I nicely implement this so that when I move to the position of the object, I can draw and place the object accordingly in my viewport and when the viewport leaves the position I don’t draw it anymore?
At least in theory, this feels like a quite effective and easy to understand way of representing a 2d game world; The arrays could be defined with higher resolution in order to place objects closer to each other, and I can adjust the scale of the world with a larger scale factor between array and world coordinates. And objects are only created/drawn when they are visible.
I started experimenting with a script that, in each update, tries to find its current position in the grid/array and identify any objects that are visible in the viewport to render, but I can’t quite figure it out. Maybe there is some easier way of doing this in Unity.

