L
L
Loshka242021-12-17 17:20:43
Unity
Loshka24, 2021-12-17 17:20:43

How to make a tile in a unit selectable, while different tiles have different properties?

I decided to practice with Tilemaps in Unity, I chose a global strategy like a civilization, with hexes. A map is made using the palette, Tilemap assigned to Tilemap Collider 2d. It is necessary to make it so that when you click on one of the tiles, a Panel with UI pops up, which will display the type of terrain, the state of the cell, etc. In simpler terms, how to make tiles clickable.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Ente, 2021-12-18
@Loshka24

Tilemaps are not very good for interactive, it's more for creating environments that don't interact with the player. I use normal gameobjects, if the map is very large and there will be a frame/memory drawdown, use the amount that is visible on the camera (+1 at the edges so that they are not cut off in the middle) and move them along with the camera, replacing their properties according to your map .
Or the second option - you can build a tilemap, and then determine with which the player interacts and pull it out of the array (your script) by the coordinates of their properties.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question