Forum rules - please read before posting.

Multiple characters in the same sorting region

Unity 2020, AC 1.75.8

Hello,

My characters are made up of multiple sprites. I use Offset original order to keep them in the right order in layer while traversing sorting map layers. This work great until I introduce a second character into the scene (a following NPC). Then, when the two characters are in the same region of the sorting may their sprites intermingle and overlap each other. I want the player to be able to walk in front of or behind the NPC while they are in the same sorting region, but don't know the best way to achieve this...

I considered using multiple sorting layers for each walkable region. For example Foreground(front) and Foreground(back) then using a script to swap the characters between front and back based on their relative Y position. But I have no idea if that is a sensible solution. And no idea how to actually implement it if it is.

help? :#

PS. I did notice that the notes for one of the more recent AC versions mentioned a fix to the way this is dealt with, but updating to the most recent version didn't solve the problem..

Comments

  • AC should compensate for this automatically by adjusting the relative "Z" position of the characters when two are in the same region.

    Are your Sorting Maps attached to the roots, or the sprite children?

    Though, I'd recommend switching over to Unity's own sorting system, if feasible. With recent releases (2020 included), improvements mean that you can use Unity's own sorting rather than AC's workaround.

    To do this, go to your project's Graphic settings, and set your Transparancy Sort Mode to Custom, and the Axis to (0, 1, 0).

    This will cause sprites - that share the same Sorting Order - to be sorted vertically. For scene sprites, set their Sprite Sort Point to Pivot to have their sort point be the same as their origin position - though you may have to adjust this pivot point in the Sprite Editor afterwards.

    Once done though, you no longer need to have sorting regions, and can uncheck the Sorting Map's Affect character sorting? option - you'll only need it to handle the resizing based on position.

  • Thanks for the reply Chris!

    I would like to avoid changing to the Unity system if possible, as I'm late in the project and I have a few scenes with slightly complicated setups that I would be afraid of breaking.

    My characters are set up as follows;
    Root containing player script etc > Empty sprite object with empty sprite renderer, Follow sort map and follow tint map > multi layer PSB with animator at root

    Not sure why I added the empty sprite object in between but I guess someone told me to or I was botching a fix for another issue that I have now forgotten about :#

  • I see that the Z position is being altered correctly, but because my characters are made of multiple sprites with different order in layer numbers that is presumably only effecting the ones with the same order in layer? If I uncheck offset original order it works correctly, but then the order of the sprites that make up each character gets messed up...

  • As an alternative to the "Offset sorting order?" option, you can attach a Sorting Group component to the uppermost sprite in the Hierarchy. It'll function essentially the same, but avoid the need to alter child sprite orders at runtime.

  • Incredible. Exactly what I needed. Thank you, Chris!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.