Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Overlaying/obscuring sprites with rectangular tilemaps basing on a "height"

Discussion in '2D' started by micdolinski, Jan 10, 2021.

  1. micdolinski

    micdolinski

    Joined:
    Feb 16, 2019
    Posts:
    4
    Hello,

    they say that picture says more than a thousand words so, below here is what I want to achieve:
    upload_2021-1-10_14-43-11.png

    I am using rectangular tilemap so the setup looks like this:
    upload_2021-1-10_14-44-8.png

    I am wondering is there something in-build into Unity tilemaps to achieve something like that?

    I assume that this most probably can be done with some colliders as triggers switching sorting layers or order of a player character but it requires some logic scripting and first I would like to check if there are other options.

    I also found something like "z-position" of a tile in default Grid Brush:
    upload_2021-1-10_14-46-52.png

    To be honest this last one is kind of enigmatic to me, not much in the docs (or I just can't find proper one). All I see is that I can somehow overlay tiles on the same tilemap in the same tile "slot":
    upload_2021-1-10_14-49-27.png
    5 and 10 are "z position"s of each tile.

    Can it be leveraged to achieve what I want? Is there a way to set player character z position which will be interpreted in the same manner as z position of a tiles, hence influencing the rendering below/above tilemap "level"?
     
  2. raarc

    raarc

    Joined:
    Jun 15, 2020
    Posts:
    535
    set transparency sorting axis to order by z

    then set tilemap renderer mode from chunk to individual

    the lower z should render above the higher z

    also you can switch scene view to 3d mode so you can accurately see how the tiles are being placed

    PS: that ramp is going to give you nightmares