Sorting Group component in Unity

When making a 2D game, if a character comprises multiple body parts, you can set the rendering order of each part using their “Order in layer” value of their Sprite Renderer.

When the character moves around on the ground, there can be some objects on and the rendering order of the character and the objects on the ground is important to make the character movement more natural. For this, Project Settings > Graphics > Camera Settings > Transparency Sort Mode > Custom Axis can be used to set the order follow the Y axis value as following.

But, the problem is that, this option only works for those Sprite Renderers which has the same Sorting layer and same Order in layer value. That means, only a part of your character is affected by above rendering order. To make your character is affected by above setting as a whole, you can use the “Sorting Group” component in your root object for your character.

If you put the Sorting Group component into your character root object, the rendering order of your character will be determined by the Sorting Layer and Order in Layer value of the character’s Sorting Group.