How can I have different variants of a tile in a tilemap?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jujumumu

How can I have different variants of a tile in a tilemap? Like if I have a dirt tile but I wan’t some variants so it’s not the same tile over and over again. Is there a way to do this easily? Or do I just have to make more tiles with the variant textures?

:bust_in_silhouette: Reply From: njamster

Or do I just have to make more tiles with the variant textures?

I’m really curious about any alternative you can think of… Of course you have to draw them yourself! One certainly could come up with a program that randomizes parts of an image. But don’t expect that to look anywhere near pretty. :wink:

No no no. I think you miss read me. Or I’m this bad at english. I already have the textures. How can I add the textures to the game. Is there a way to change the texture of a tile. Or do I have to add like 3 more tiles to add the variant textures. Ex: I have a dirt tile. Repetition is boring. So I make 3 similar dirt textures. Then I randomly choose one.

jujumumu | 2020-03-29 03:12

Ah, alright, now I got it! :slight_smile: Does this feature fit your needs? To recap:

  1. Put all your dirt-tiles in one single image, a so-called texture atlas
  2. Next add this whole image as a texture to the TileSet used by your TileMap
  3. Click on “New Atlas” (in the top-right corner of the TileSet-edit-view) and drag the mouse from the top-left to the bottom-right corner of the image to draw an grid. Each cell in that grid will equal one tile in the atlas. You can edit the cell-size in the Inspector under Selected Tile > Subtile Size to fit your needs.
  4. Now select your TileMap-node, choose your atlas-tile in the tile-overview on the right and make sure “Enable Priority” is checked at the top of the view.
  5. If you now place a tile (while the atlas is selected in the tile-overview), Godot will choose a random tile from of the atlas for you. By default all priorities are equal, so each tile has the same likelihood of appearing.

You can change the priority of a specific tile by clicking on it’s cell in the TileSet-edit-view and clicking on the “Priority”-button. That will open up an input field below it, where you can increase the tiles priority by clicking the up-/down-arrows next to it.

njamster | 2020-03-29 12:06

This is exactly what I needed! THANKS

jujumumu | 2020-03-29 17:17