I’ve been making a 2D tile-based pixel art game and have found great difficulty with sprite sorting.
What I would like to be able to do, ideally, is have different parts of a sprite sorted separately, ex. on different sorting layers or treated separately with respect to custom axis sprite sorting. That would rather beautifully solve all of my problems.
I suspect this is not (easily) possible, as I have looked at many unity discussions where such a feature would be the solution.
What might be possible (by my reckoning) could be having individual tiles in the tilemap composed of multiple sprites, such that those sprites are treated separately. If I could do that, it would be a suitable workaround to my problems.
As a side note, even if the above is not possible, I would love to know if there is a way to set a custom pivot point for sorting without moving the whole sprite to be centered on it. I get the sense, from what I’ve seen, that this isn’t possible, but using pivot points has meant splitting things into far more tilemaps than I need (each offset differently) so the tiles remain centered.
For an example of the sort of thing I’m trying to do:
I’ve achieved what I want with this bush using the pivot workaround, but I’m using a dual grid tilemap system for many of my tiles. Achieving this effect with a tile like the hedge below the bushes is my goal.
You can’t have multiple sprites on one tile (even with custom tiles) but you can assign multiple tiles to the “same” location (ok sorta). Just offset the z-value. This can make it look like there are two sprites on one position even though really it’s two different positions. You might/not want to adjust the Grid or sorting axis so it offsets a tiny amount for different z’s if there’s z-fighting. But first see if the below (offsets) might work for you…
Hmm. You can offset it within a grid position. So if you put a tile on (1, 1, 0) you can also add an offset within that slot. Would that work? I can’t remember if there’s a specific brush for this but you could always make a custom brush if you have a consistent or randomized desire to edit these little offsets. Custom brushes, if you haven’t already discovered, can greatly improve your workflow.
Unfortunately I don’t quite know your intention is here. Remember it’s usually really hard to know this from a still image on the forums! The character is wearing the bush… as a hat? Hopefully one of the other suggestions works.
If you have special tiles that are specially troublesome, don’t hesitate to revert to a gameobject with a Sorting Group. That can solve most problems.
If this impression is correct, I’d definitely steer you to a gameobject + Sorting Group with other SpriteRenderers positioned how you want the sorting to go. The above suggestion of offsets won’t work to fix this kind of sorting issue so don’t try that.
Thanks for the tip about custom brushes. I had not encountered those yet!
What I was attempting to demonstrate was just that the whole bush displays behind the player except for the top layer of pixels, where the bush is in front of the feet. The player and bush both being green does not help my demonstration. In this bush’s case, it’s just a matter of the pivot point being near the top of the sprite, and I was showing an instance where my problem is essentially solved.
I’ll look into trying to use gameobjects and sorting layers for more complicated sorting needs.
Appreciate the help!
A common trick is to use multiple sprites to form a single sprite character. Back in the day we used that technique to give the player character more than the technically possible 4 colors on GameBoy Color by overlaying additional sprites.
In its most extreme case, you could have each pixel of the character be a separate sprite and sorted separately. Probably overkill though.