Is it a good idea to store gameplay info in tiles

I have a tilebased game so I’m using Unity tilemaps I know you can extended from tilebase and store some tile data there. So is it a good idea to store gameplay informatioin right in the tile, for example.

public class MyBaseTile : Tile {
    public int WalkSpeed;
    public bool CanWalk;
    public BaseUnit CurrentUnit;


Hard to say without knowing what you’re really going for, but here are some considerations:

  • If WalkSpeed and CanWalk differ from tile to tile, like swamp tiles reducing walkspeed and road tiles increasing walkspeed, you naturally have to store this somewhere. You might want to consider assigning each tile just a type like “swamp, forest, road” etc. and map those tile types to different values of WalkSpeed and CanWalk. ScriptableObjects are great for this kind of thing.
  • Assuming CurrentUnit means the unit currently on this tile, the way I’d personally do it would be to add a location or coordinates variable to BaseUnit as well as the tile. So if you want to know what units on your tile with coordinates 1,2 you loop through your units and find the unit with its location set to 1,2. This way you don’t need to update the CurrentUnit variable on multiple tiles each time a unit moves, which might have been error prone.
  • Something else to consider: does your game allow saving of player data? If it does, how are you going to serialize tile data? I’d recommend storing the data in a custom class of your own design because then you have more control over the serialization process, whereas Unity classes may be tricky to serialize sometimes if they have dependencies you’re not aware of under the hood.