Forum rules - please read before posting.

Skeleton SortingMap Ordering

Hi all,

Hope you are all having a wonderful holiday break!

I was wondering how I can adjust the sorting map presets so that my main character will correctly interact with its environment.

So far, I am having two issues:

1) My character's parts overlaps with other skeletal NPCs when the character is near it. How can I avoid this? Screenshot attached.
https://drive.google.com/file/d/1PnO5zq2vyQsAcj3BX4_T4gHSibUvxy1H/view?usp=sharing

2) My character interacts strangely with the sorting map.

My character has a different sorting order within the layer for each of its body parts (e.g: arm = 1, hair = 0, etc.); for this example, say that all of its body parts are within the order of 0-8.

There is a piano at order 50.

When my character clicks behind it, its body parts should stay between layers 0-8. However, when it clicks in front of it, its body parts should range from 51-58. How can I achieve this?

Thank you!

Comments

  • For each character, attach a Sorting Group to the same object that has the "Follow Sorting Map".

    This is a Unity component that allows child sprites to retain their Sorting Order values relative to one another, but all rely on the Sorting Group for ordering relative to other objects.

    AC will rely on this component if found - so Sorting Maps will only affect the order of the Sorting Group, and not the children within it.

  • edited January 2

    Ah thank you so much! @ChrisIceBox

    So I tried this, and it seems like the sorting map is working, but with a very heavy offset (for some reason, it's not accurately detecting the sorting order of the map at the right position -- do you know why this may be?)

    I attached a video with the values of my character and me playing around with the sorting map.

    Seems like the character is still at order 20 even though it's supposed to be at order 1, if that makes sense!

    Video: https://drive.google.com/file/d/1jPYwqtnMB8B5hTBRgIexvp6nwCQbnPMk/view?usp=sharing

  • edited January 2

    Odd - I can't see why that'd happen.

    If you come out of 2D view in the Scene window, is the Sorting Map pointing straight upwards, and has the same Z-position as your character?

    We'll need to figure out if this is down to the character, or the scene. If you temporarily replace your Player character with that of the 2D Demo, Brain2D, does he have the same issue? His prefab can be found in /Assets/AdventureCreator/2DDemo/Resources.

    One point to mention is that the use of the Sorting Map to control sorting is now optional, given improvements to Unity itself.

    If you uncheck the Sorting Map's Affect character sorting? option, sprites will rely on your project's Transparency Sort Axis value, set in the Graphics section of your Project settings. As an alternative, you could try relying on a value of (0,1,0), unchecking the option, and setting your various scene SpriteRenderer Sprite Sort Point values to Pivot. This would cause sprites to be orderered automatically based on the Y-position of their pivot points - avoiding the need for the Sorting Map (which can still be used for scaling, however).

  • Ah yes! It looks like both the sorting map and the character are at z-position 0, and the sorting map has an x-rotation of 90 degrees!

    Ah thanks for the heads up! If I'm unable to fix the sorting map, I'll go ahead and try that out as well!

    It doesn't look like Brain has the same issue!
    Do you know what I may need to change?

  • edited January 3

    It looks like both the sorting map and the character are at z-position 0, and the sorting map has an x-rotation of 90 degrees!

    That'll be correct for a 2D scene.

    I wonder if its pivot-point related. Are your character's root object, and "Sprite child" object, both positioned at their feet?

    Try moving the Sorting Group component to the root.

  • Hm that seemed to yield the opposite effect -- looks like it's constantly at order 1.
    What values should be checked in the "follow sorting map" component?

  • Re-watching your video, it does look likely to be a pivot issue - EverlynSkeleton has a local Y-position of -2.4, which I'd expect is the same height error difference you're seeing with the Sorting Map's position.

    You might have luck moving both the Sorting Group and Follow Sorting Map components to the root, but ideally the skeleton object would have a local position of (0,0,0) - though correcting this may involve rebuilding the animations.

    If all characters had this offset, though I suppose you could just account for it by increasing the Sorting Map's Y value by 2.4.

  • Got it, thank you so much!

    Seems like my other character is at the base (0,0), so it doesn't have the same issue -- so I went ahead and just changed my animations to be at 0,0 for the Everyln character.

    I think things seem to be working now so really appreciate all the help -- thank you! :)

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.