Forum rules - please read before posting.

Sorting Map for NPC not working after switching scenes

Hi there, I'm having a really confusing problem regarding sorting maps and scene switching:

If I start the game in scene A, the player can move in front of and behind an NPC and everything is rendered correctly. But if I switch to Scene B (using a Scene Switch action) and then switch back again to Scene A, whenever the player stands behind the NPC he will be displayed above the NPC. The player standing in front of the NPC still works as expected though...

Both the player and the NPC have the "Remember NPC" and "Remember Transform" components, and both their sprite childs have the following set to their "Follow sorting map" component:
Follow default Sorting: checked
Offset original Order: checked
Also affect children: checked

The sorting map is set to affect sprites: "Order In Layer"

Using version 1.64.5

Comments

  • I should also mention that this problem only occurs when both the player and the NPC is standing in the same sorting map region.
  • edited August 2018

    I know how hard it is to reproduce bugs so here's a minimal repro that illustrates the problem clearly:
    <REMOVED BY ADMIN>

    Instructions:

    1. Play Scene1 (located in the Assets/Korath/Scenes) and notice that the NPC (that was teleported there in the OnStart cutscene) renders fine in relation to the player

    2. Go through the door (switches to Scene2)

    3. Go back trough the door (switches back to Scene1) and notice that the player is now rendered on top of the NPC (although standing behind him)

    Clue:

    Locate the “EnterFromScene2” Player Start in Scene1 and change the “Previous Scene” from “Scene2” to “” – the NPC will now be rendered correctly…

  • I have removed the link you posted as it made AC publicly available - see the forum rules.

    AC is a commercial product, and even if the intentions are good, I cannot have links to it posted on this site.  Please do not let it happen again - I have, however, gotten the project beforehand so will look into the error.
  • This was because your "EnterFromScene2" PlayerStart has a non-zero Z position, causing the player to be placed behind.

    Also be mindful that your SpriteRenderers all have a starting Sorting Order of 50, and since "Offset original value?" is checked in their Follow Sorting Map components, they'll also be this value at runtime.
  • Ah... Beautiful, thank you so much!

    And apologies for exposing your source - won't happen again (and I deleted the download).

    A quick bonus question since you did manage to look at the repro: Could you also tell me why my characters are all facing up rather than down by default?
  • A rotation of (0,0,0) equates to facing "up" in 2D.  You can use the Character: Face direction Action in your scene's OnStart cutscene to set their original facing direction.
  • Ah, thanks!
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.