Search Unity

Tilemap walk behind Tiles

Discussion in '2D' started by Deleted User, Sep 25, 2019.

  1. Deleted User

    Deleted User

    Guest

    Hi im working on a simple pixel game with a tilemap.

    Here is an Image of it.
    PixelGame.png

    As you can see the player stands behind this wall. I solved this by using two tilemaps with different sorting layers.
    Now i want the player also to walk in front of the wall. Has anyone an example how to do somthing like this or maybe an idea?
     
    Last edited by a moderator: Sep 27, 2019
  2. Cenphon

    Cenphon

    Joined:
    Jul 18, 2019
    Posts:
    6
    Maybe for all of the tiles that have height (the player could walk behind them) make a script that has an if else

    if(Player.transform.position > transform.position)
    {
    //Sortinglayer for covering player
    }
    else
    {
    //Sortinglayer for not covering player
    }
     
  3. Deleted User

    Deleted User

    Guest

    Nice idea but as far as i know you can't change the sortinglayer of a single tile. But only for the complete tilemap. Or are I wrong?
     
  4. Cenphon

    Cenphon

    Joined:
    Jul 18, 2019
    Posts:
    6
    I don't know, I have never used tilemaps. You may want to consider trying to make a custom tilemap-like loader with sprites instead.