In Unity2D, I have the Transparency Sort Mode set to Custom Axis so that my objects will correctly layer themselves using the Y axis. The problem comes in when I try to layer sprites on an individual object basis. Taking this tree for example. I have my player (capsule) who is in front of the tree. The tree is cut into two individual pieces; the stump, and the rest of the tree. Because the top portion of the tree is above the stump on the Y axis, the stump displays in front. The player, however, is correctly displayed in front of the entire tree. If I try to create a sorting layer called “tree” and sort the two objects appropriately, the tree now ignores the Transparency Sort Mode because it belongs to its own layer. That fixes its own sorting issue, but now the player will always be either behind or in front of the tree, visually, based on where the ‘tree’ layer is placed. How can I go about solving this issue? I can’t seem to find anything by just searching online and I’ve been racking my brain for a while.
Because sorting layer has a higher priority than Transparency sort mode in the render queue, your tree, stump, and player will always be rendered in that specific order, regardless of what your other settings are. Take a look at 2D Sorting for more info.
One way to make it work is to use Sorting Group. If you group your tree and stump, attach a sorting group component and have them on the same layer as the player, they should be sorted properly with transparency sort mode.