Grid System Visual Code separation from Grid System

What made you decide to separate the Grid System Visual into another script ? My initial thought was to put it in GridSystem.cs script similar to CreateDebugObject() since there is already a loop being done in the constructor.

Is it because GridSystem is mainly just to create the structure and you are separating the visuals logic from this script ? And the CreateDebugObjects is just a helper tool for this script and it could easily be just in another script if i wanted it to.

1 Like

It allows for more flexibility. It’s our representation of the grid to the player. This changes from game to game and can be as simple or complex as we want it to be. Keeping it separate from the grid system keeps the code clean. The debug objects could also have been separated out into it’s own script. We like to separate logic from visuals

2 Likes

You should always attempt to separate logic and visuals as much as possible so you can reuse the logic without having to reuse the logic.
For example, later on in the course the Pathfinding uses the exact same GridSystem but has no need for a visual. If you made the logic and visual tightly coupled then you’d have to make the Pathfinding destroy the included unnecessary visual.
Debug Objects are meant to debug the logic and see the inner workings of the GridSystem, they’re not intended as a final visual, so because of that it makes sense to place them alongside the logic.

2 Likes

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

Privacy & Terms