Hi,
I work as a freelancer for a game studio and we’re prototyping a 2D isometric RPG, very similar to classic Fallout titles. In fact, we’re trying to build fairly precise equivalent of the original engine/technology used in classic Fallout titles witin Unity.
Unlike many tile-based 2D games, our game (just like classic Fallout games) is supposed to use tiles that are not shaped after the placement grid. Tile placement and gameplay logic uses special hexagonal grid, while various types of tiles (rendered in trimetric projection, which corresponds with point-top hexagons stretched in 2:1 (X:Y) ratio) have different shapes.
Example:
We decided to use Tilemaps for all static tiles and preferably static/stationary props, as from the technical standpoint, it seemed to be the most performant solution for our case (large amount of sprites with layers and sorting concerns). We figured out the correct setup for the Grid Layout and our tile sprites. We’ve also created custom mapping/tile placement tools to substitute missing features within native Tilemap tools. However, there’s one huge technical obsticle we haven’t been able to overcome.
Due to the design requirements, we need a certain level of environmental context implemented. For example, hovering a cursor over any structure tile (walls, doorways, etc.) or prop would result in a simple text description of the object. Additionally, dynamic/animated tiles also require interactibility with cursor (opening/closing doors, etc. - essentially a need to trigger such behavior with a mouse click). For that purpose, we intended to implement custom data structures and functionality into derived Tile classes.
The problem we subsequently discovered is that there seems to be no way to retrieve individual Tile data from the tilemap. Common way to get Tile object instances rendered in the tilemap is to use the grid coordinates and call a GetTile function on a Tilemap component. Of course, that is only applicable for tilemaps and grids that use tiles with the same shape as the grid (i.e. hex grid = hex-shaped tiles, etc.).
We tried to use physics to raycast and retrieve Tile objects based on the sprite-shaped collision, although Unity does not provide any way to access individual Tile colliders with neither Collider component. Tilemap Collider component apparently batches all subcolliders into one collision mesh, so the result of raycasting is always th entire collider.
Basically, what we need is to be able to interact with Tiles based of their sprite shape, not the grid shape or position.
The only possible solution we see is to switch to using regular Sprite renderers for all objects that require any sort of interactivity, although we are concerned about the performance impact of such setup, as well as possible workflow overheads in the future.
Is there any way to get around this without having to resort to use Sprite renderers at all? Any hacky way would do in this case.
Alternatively, does Unity plan on enhancing their Tilemap codebase to support such features, or at least exposing more of the native code for us to code them ourselves?