Search Unity

Tiles with different properties, how to do that?

Discussion in '2D' started by MrMikpik, Feb 18, 2020.

  1. MrMikpik

    MrMikpik

    Joined:
    Dec 11, 2019
    Posts:
    10
    Is there a way to add tiles with different properties other thank its own texture?
    What I mean is, when creating a tilemap, I am able to place tiles on the grid, but what if I want specific tiles to have different properties, like a tile without collision or, taking as an example strategic games, a mountain tile which gives you more defense than a plain tile?
     
  2. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,511
    You may want to get started by looking at Unity's example projects:
    https://github.com/Unity-Technologies/2d-techdemos
    https://github.com/Unity-Technologies/2d-extras
    https://github.com/Unity-Technologies/2d-gamedemo-robodash

    There are several approaches you might try: one might be deriving a new kind of TileBase that overrides GetTileData, another approach might be setting the a tile then modifying its properties through setting the tilemap.

    There's general documentation for Tilemap here: https://docs.unity3d.com/Manual/Tilemap-TileAsset.html (and note other links to the left under 2D > Tilemap). There are also official and unofficial YouTube tutorials easily searcheable.
     
  3. MrMikpik

    MrMikpik

    Joined:
    Dec 11, 2019
    Posts:
    10
    Thanks for the reply. I wrote this thread because on yt I found no one talking about it, just about normal and rule tiles.