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

2D Rig Animation sorting problem in a map

Discussion in '2D' started by Hector-Xiang, Jan 21, 2022.

  1. Hector-Xiang

    Hector-Xiang

    Joined:
    May 2, 2014
    Posts:
    4
    Hi all,

    Sorry if there is any grammar problems, I'm not a native English speaker.

    I've got a problem in managing sorting order for a rig 2D animated character in a map with buildings. It should look like this,
    upload_2022-1-21_20-56-27.png
    But sometimes it shows like this:
    upload_2022-1-21_20-57-15.png
    Some parts are hidden behind the building. I changed the sorting orders of all the parts to ZERO and modified the Z position of them carefully, but this broke the animation:
    Correct animation:
    upload_2022-1-21_21-0-39.png
    Wrong animation:
    upload_2022-1-21_21-1-23.png
    The left arm is hiding behind the body.

    Is there anyway to manage the animated character's sorting order in a map with buildings without breaking the animation?
    I'm working in Unity2012.2.8f1c1, BTW.

    Thanks in advance.
     
  2. Unrighteouss

    Unrighteouss

    Joined:
    Apr 24, 2018
    Posts:
    599
    Hey,

    Instead of changing the sorting order of each sprite object, add a Sorting Group component to the parent. This will keep the character's sorting order correct, but will treat the character like a single sprite in relation to the rest of the world, so you won't get issues where parts of the character are obscured.

    Hopefully I explained that in a way that makes sense. If anything is unclear, please let me know.
     
    Expar and MarekUnity like this.
  3. Hector-Xiang

    Hector-Xiang

    Joined:
    May 2, 2014
    Posts:
    4
    Nice, it totally fixes the issue, thanks a lot!
     
    Unrighteouss likes this.