Hi there,
I am setting up a grid of tiles at run time, 10x10 for example.
What I am wondering is, I want to mark some of these tiles and am struggling on how to do so via code. So, for instance, I want tile 3,3, 2,2, 1,5 and 3,9 to be marked.
How would you do this? I am thinking an array, but I cant quite sort it.
Thanks
Yes, an array is probably what you are after. Look up the C# syntax for arrays (or Javascript if you prefer) and work through some of the examples until you understand the syntax.
I’m guessing perhaps either an array of boolean values (true/false) to represent whether an item is marked, or else you could simply make a more-complex class containing a boolean for marked as well as any other information you might need about the tile.
Additionally, in the Unity world, you could put a “marked” script on the tiles you care about that causes them to do something that indicates to whoever you care about that “Hey, I am a marked tile.” It sorta depends on what you’re trying to do with it all.
Yah I sorted it. I just created a separate map class. This class knows all tiles on the board by row. I just set a value of 0 or 1 to each. This is passed to each tile unit when a new board is ran.
Cheers!