The SortingMap system is quite nice, and I really like how easy it is to tweak order and fake perspective with it in a 2D scene.
However, when multiple NPC's are walking around they don't order properly when overlapping each other.
Is there a way to use SortingMaps and if 2 characters are in the same area, the top one on the Y-axis will always be sorted behind the lower one?
Both characters are 2D and have sprites with child sprites that are offsetted a little bit.
Before I was using AC, I did it something like this:
order = (int)-(Mathf.Round (transform.position.y * 100));
sprite.sortingOrder = order + offset;
My guess is the easiest way is to create a custom version of FollowSortingMap?
I am a lousy coder, so any advice or help would be appreciated!
Comments
However, testing this just now suggests there's a problem with it. Though the position is changing correctly, it's not affecting the rendering order as it should - it could be that this is due to a change in Unity. What version are you using?
Do they then play nicely together? When two characters are within the same Sorting Map region, you should find that the Z-position of one of them is offset by a very small amount (around 0.001) - is this happening, even if the sprite ordering itself is still wrong?
You will also need to set your character sprite's positions to (0,0,0), so that they are at same position as their root objects.