Godot Version
4.6 beta
Question
Just a sort of general architectural question, and I’m sure it depends on the game. But I’m a total beginner to this kind of structure and am working on a super small FE-like game for a game jam (one map, no items, just a few characters).
I’ve created my Unit class, which just holds things like stats for now, and presumably things like types of attacks later.
I also have a GameGrid class, which holds info about all the tiles on the board and a dictionary for what tiles have Units in them.
Now I’m working on implementing AStarGrid2D to do movement. I started by putting that in the GameGrid class, and setting it up to set walls as solid points.
Then I wondered how Units should… actually use that to move. I sort of instinctively threw my tree together like this to start with:
So then I thought to myself, well, I guess the Map node should perhaps handle things like the game state and selecting units, since it is the parent of both. (Maybe Units don’t have to be a child of GameGrid, either.) So if the Map handles that sort of thing, maybe the Map should just give units the info they need when they move. i.e., it passes them an id_path using the GameGrid’s AStarGrid2D, then the units use that to move in their physics processes.
So, I implemented that and then got it working.
But then I got to thinking… what about when they need to attack? We need to find their available targets and such… and then movement ranges, too; we need to somehow limit the pathing to a range. Then if you were to add anything like board-based skills to the mix, or different movement types, too… I wondered if it made more sense to just give every unit their own AStarGrid2D and a reference to the GameGrid.
How, in general, would you go about approaching this? Does it make sense for each unit to have access to the grid?
