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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Overlapping Corners Problem

Discussion in '2D' started by UnityGui123, May 12, 2022.

  1. UnityGui123

    UnityGui123

    Joined:
    May 12, 2022
    Posts:
    3
    I've been trying to rebuild part of a fairly simple GBA game for the sake of learning the basics of Unity but I came to an halt pretty early since I can't really figure out this fake 3D effect. When I approach the corner of a wall I am supposed to be hidden behind the wall but only partly. I created this video since I can't describe my problem all that well.
    I tried tinkering with layers but it doesn't seem feasible.
     
  2. Unrighteouss

    Unrighteouss

    Joined:
    Apr 24, 2018
    Posts:
    599
    So you need to sort the sprites orders by their Y positions. The easiest way of doing this is to go to Project Settings -> Graphics -> Camera Settings -> Transparency Sort Mode and setting that to Custom Axis with X and Z being 0, and Y being 1.

    Make sure the pivot of each sprite is where you want them being sorted by. So for example, if you want the character to pass behind a wall when passing its bottom edge, the pivot of the wall needs to be at the bottom edge. You can change the pivot of a sprite in the Sprite Editor of that sprite's inspector.
     
    Last edited: May 12, 2022
    UnityGui123 and karliss_coldwild like this.
  3. UnityGui123

    UnityGui123

    Joined:
    May 12, 2022
    Posts:
    3
    Thank you for your reply but I tried your method and it's still not really working. So I went ahead and just made this part not accessible by foot. But I found out a couple of seconds later that this won't fix my problem since I can't just block everything off. This one partis just too narrow so I need to go behind the wall. That's how it looks:
     
  4. UnityGui123

    UnityGui123

    Joined:
    May 12, 2022
    Posts:
    3
    Okay, now I found out what the problem was. The order of both layers needs to be the same otherwise the pivot settings do nothing.
     
    Unrighteouss likes this.