Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Tilemap renderer as a mask

Discussion in '2D' started by alkaitagi, Jun 13, 2019.

  1. alkaitagi

    alkaitagi

    Joined:
    Dec 8, 2016
    Posts:
    87
    Hello. Is it possible to use tilemap as a mask? Say I have a particle effect and want it to be visible only behind tiles.
     
    RemDust likes this.
  2. Primoz56

    Primoz56

    Joined:
    May 9, 2018
    Posts:
    369
    you can always try, but it sounds like it should. if mask component doesnt work, try spritemask
     
  3. alkaitagi

    alkaitagi

    Joined:
    Dec 8, 2016
    Posts:
    87
    As indicated by name, sprite mask takes a sprite as mask shape. I need to use tilemap as mask shape instead.
     
  4. od3098

    od3098

    Joined:
    Apr 29, 2015
    Posts:
    56
    You can create a sprite mask prefab with the same size as your tiles in tilemap.
    If your tilemap is rect, simply instantiate your mask prefab and scale it up to cover your tilemap bounds and move it to the correct position to mask your whole tilemap.
    Else instantiate separate prefabs per each tile in your tilemap.
    Obviously using the first approach has more performance.
    There should be a way to inherit from spritemask and pass tilemap renderer but I'm not sure about that.
     
  5. eldarion

    eldarion

    Joined:
    Jun 30, 2014
    Posts:
    1
    I'm working on qix/volfied clone project. I navigate my player on tilemap and generate new paths as tilemap cells.
    My question is can i use tilemapcells to mask graphics like in volfied.

    Is it possible to mask sprites with using sprite mask and tilemap.
    Is there any solution on using tilemap as a mask?
     
  6. rarac

    rarac

    Joined:
    Feb 14, 2021
    Posts:
    570
    no, maybe with a shader but thats a lot of work