- Home /
2D tilemaps - separation of view and data, prototyping doubts
I'm prototyping a top down tile-based game in Unity, and, as many before me, have found Unity's tilemap system helpful, but lacking. First of all, manipulating tiles and checking the tile data (for pathfinding and LOS calculations, not to mention custom tiles) is easier when using a dictionary or array, so I found myself iterating over tilemap at startup in order to create a dictionary out of it. I understand this is a temporary solution though, so I'm thinking about making a custom tile brush that will populate a dictionary asset in real-time, just as I paint tiles on the tilemap. This feels wrong, however - it would mean I will effectively store the tilemap data twice - both in Unity's tilemap assets and in my own dictionary classes (serialized to JSON or whatever). The tilemaps would also be duplicated at runtime. Is this the wrong way to do it? I mean, it obviously is, but what other options are there, except rolling out my own custom-built tilemap system/renderer that would use my custom dictionaries to make a draw calls and paint the tilemap? Any insights would be greatly appreciated.
I'm in the same situation as you are, prototyping with the tilemap and still not entirely sure how viable this solution is going to be.
Have you checked the 2d-techdemos repo? There are some interesting examples there that might help you find out how you can embed logic into tiles, such as pathfinding or LOS. However it doesn't always feel super intuitive or convenient, so it might actually be way easier to just use whatever data collection that stores all your relevant info for your computations.
$$anonymous$$y current view on the subject is that, as it is, the tilemap system is useful for a single purpose: rendering stuff. As you pointed out, even the way it stores the data is kinda annoying... If you need need anything more complex than a few colliders (say, for player navigation or LOS), it feels like the tilemap isn't going to help you in any way.
That was my 2 cents on the subject, not sure that was actually very helpful. Also, I believe a forum post would better suit an open question like that. ;)
whoa, thanks for responding, some of what you've said are exactly my thoughts: current tilemap system is fit for rendering only, otherwise it gets complicated very quickly. Thanks for the advice and the links. Indeed, I'll recreate this question on forum and maybe we'll get something (maybe guys from Unity themselves will take notice).