How to Attach Variables to Objects?
Im working on a tile based boardgame. The Player moves one tile after another ahead, so only the adjacent ones should be reachable which works in theory fine with physics.overlapbox. But how can i set each tile a boolean variable like "walkable" and access them from another script? Actually a really simple problem but im a real newbie to c#... Thanks in advance
Answer by eses · Aug 21, 2018 at 02:39 PM
Hi @harryer
This is not a Unity or C# question, it is more like about knowing proper approach or method how create movement and collision system for tile / grid based games.
Ditch the idea about colliders and raycasts. You will be better off using data to see what is what in any particular tile. This is how it was done often in old tile based games.
See other threads like this one (or do a search about tile / grid based movement in any language):
https://answers.unity.com/questions/955127/how-to-detect-collision-of-a-wall-with-grid-moveme.html