Two Characters with Body Parts, Layer & Sort Order

I am working on a 2D project that has small characters walking along the ground. The characters are composed of body parts such as “Head”, “Eyes” and “Feet”. Historically I’ve used varying Z positions to push sprites in front or behind other assets. However this time I thought I’d give the layers and sort order a try.

However, If I assign all eyeballs a “Layer ‘Character’, Sort Order 4 (Eye Ball)”, then when two characters pass by each other the eye balls from the character in back show through the character in front.

It’s almost like every character would need to have it’s own layer, which of course isn’t feasible.
Does anyone else have experience with this kind of multi-part sprite system? Thanks!

You could dynamically change the sorting layer of your characters when detecting an overlap by accessing the sortingLayerID property of the SpriteRenderer.

When 2 characters overlap(or more), determine which one should be placed in front, and put the sorting order of the other characters in those respective sorting layers: “HeadBehind”, “EyesBehind”, “FeetBehind”.

Thanks for the reply Sheikz. I was hoping there was a non “dynamic” approach, but I guess not. I like your idea of dynamically adjusting only those currently overlapping, it means I can get away with a lot less comparisons and adjustments. Thanks!