Grid System - Expanding the Grid

So one of the things I would like to do is have the player able to increase the amount of grid they are working with as a mechanic. For example lets say the player starts in a grid section. They can build and move around within it, but they also have the option to expand the grid in any of 4 directions attached to that grid piece (2D top down).

Should we make / instantiate multiple grids and link them together / allow them to interact or make just a really large grid and reveal parts of it when they attempt to explore. Which would be the best method to tackle this and how would you suggest going about it?

I found a similar visual working example of this is in the steam game “Rogue Tower”.

You can make a very large grid but at some point it may just get too large.

Personally, I would have some sort of ‘chunking’ mechanism to manage multiple grids. One of the problems you would have to solve, though, is getting neighbour cells from adjoining grids. If you assume ‘infinite’ grids, you can simply check if a grid position is valid and if it’s not, then it will be valid on a neighbour grid. You can then just determine which grid this neighbour grid would be, and work from there. It will be very much the same as determining neighbour cells, but on a grid scope since your grids are likely to be arranged in a grid pattern themselves. You would also want to give each grid an offset, since the grid from the course does all its calculations with the assumption that it is positioned at (0,0,0), while multiple grids would be offset across the world

1 Like

Yeah it depends on what scale you’re thinking about, at a certain point you need multiple grids.
However if you want a grid of a standard size, and simply have some positions unusable until later on, you can just add an extra field on the GridObject to define if its usable or not.

In the beginning start with only a few grid positions usable, then when the player moves ahead or triggers a cutscene of something expand the area by marking a few more grid positions as usable.

1 Like

What would be the best way to handle placing buildings on a tile system similar to what we made that take up 1x2, 2x1 and 2x2 tile area’s?

Funnily enough his latest video addressed that very question: https://youtu.be/53oV_yuFyLU

2 Likes

Hugo did a video on this a little while back: https://youtu.be/dulosHPl82A

1 Like

I did something a bit different with my Gridsystem… rather than storing the data as
GridObject[int, int], which essentially quadruples the grid size with each doubling of the grid size, I made my grid as a Dictionary<GridPosition, GridObject>.
If a location tests as static and unpassable, it simply never gets an entry in the system. IsValidGridLocation just checks to see if an entry exists, no complicated checks required.
This funcitionality would support adding new GridPositions as you move outwards/construct, etc. That being said I haven’t done anything with it beyond taking advantage of the reduced size in the GridSystem.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms