Forum rules - please read before posting.

Wrong z-order between player and NPC after NPC move-to-point

i'm having this strange issue: after an NPC is moved in scene, the sorting layer between the player character and the NPC is broken...
Im working in 2D.
Here an example:


  • edited October 2022

    Are you relying on a Sorting Map, or Unity's Transparency Sort Axis?

    If you're using a Sorting Map, check that the NPC and Player start positions both share the same Z-value.

    Though, with recent updates to Unity, it's a lot easier to get correct sorting without the use of a Sorting Map - just make sure your Sprite Renderers have their Sprite Sort Point set to Pivot, and set the Transparency Sort Axis to (0, 1, 0) in Unity's Graphics settings. You can then uncheck Affect character sorting? in the Sorting Map Inspector.

    This process is covered in the 2D Primer tutorial here.

  • I'm using a Sorting map, I've checked the Z-values of the NPC and PlayerStart marker, but the issue is still here: the strange thing is that it happens only when the scene is re-loaded from another scene. Here an example:

  • edited October 2022

    What of the Z values at the time the issue occurs?

    If both characters Sprite Renderers share the same Sorting Order, then their sorting order will be down to their relative Z positions. The Sorting Map will adjust the Z-position of characters in the same Sorting Map region to correct their display.

    If you'd like to PM me a .unitypackage of the Managers/scenes/character prefabs of your first video example, I can take a look directly to see what's causing the issue. However, the Unity method I described above doesn't need to involve Z-offsetting, so switching to that method would fix it.

  • The Z value is 0.001 for both player and NPC, i PM you the managers, tnx! Here the first example where u can take a look at the values and settings:

  • I'm having the same issue with sorting maps - they work fine if I'm testing only one scene, but if I start scene #1 where the NPCs are, switch to scene #2, and then go back to scene #1, I get sorting errors like these. Did you ever get to the bottom of this?

  • I think this is a conflict with the Remember NPC script. If I remove the component and just use a Constant ID instead, the sorting doesn't break (but obviously I lose the Remember NPC functionality).

  • It is being looked into.

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.