So I want to implement a grid system in a tower defense game so players can place their towers. One way I’m thinking of doing it is by just having 1x1 planes represent one grid tile, and just piecing them together. Checking for things occupying that grid tile would be done by raycasts.
Is there an easier, faster or more efficient way of doing this compared to what I have in mind? Depending on how big the map is, having dozens of planes would get annoying.
Is there an easier, faster or more efficient way of doing this compared to what I have in mind?
Another possible alternative:
Have one large plane, raycast on it, from the Raycasthit, you can manually compute which imaginary grid you are pointing at. However, I still think that your original idea is a better way to do it.
Depending on how big the map is, having dozens of planes would get annoying.
There are a certain upper limit on how big a TD map is going to be, at most you will have a 30 x 30 or maybe 35 x 35 map, anything larger will kill the balance of the game. So it is not really that much of a hassle to place the unit-size plane on those grid. Furthermore, in a classic TD game, there are locations that you cannot place a tower: the routes your enemies are using; so manually placing the grid gives you more control.
A way to simplify this is that you can generate the grid at Start(), so you don’t have to do the manual work, then you can throw in some extra logic to destroy some of those plane that is not supposed to be there (those placed on the enemy route).