Forum rules - please read before posting.

NPC issue with sorting map after Object Teleport or Move to Point

edited September 2024 in Technical Q&A

Hello,

I am having a peculiar issue with an NPC (Out of the blue).
[2D game adventure game point and click style]

Premise:
1. It is an NPC that works well in other scenes respecting the sorting map.
2. In other scenes it is teleported OnStart and can use "move to point" respecting the sorting map and relative to the player.
3. The NPC has Following SortingMap enabled "follow default sorting map"
4. It has also a Sorting Group, order in Layer 0 (Default)
5. It has also a "following NPC", set OnStart.

What is happening:
1. When the NPC OnStart is without "object teleport" and IF is not using "move to point" is respecting the sorting map and is working well relative to the Player (Main character).

  1. IF the NPC is object teleported the player is falling behind it as if the sorting map that was working until seconds before is not working anymore.

  2. IF the NPC is teleported, the player is always falling behind, even if is closer on the sorting map, even if on start was working properly.

I have no idea what is triggering this, because in another scene I can "object teleport" it and I can make it do "move to point" without this issues presenting itself. I am confused because this works well everywhere and suddenly is changing the behavior after the teleport or the move to point.

Recap:
The issue is that using object teleport and character move to point, somehow, makes the npc lose the sorting map placement hence the player does not display correctly, always falls behind the NPC.

Additional info:
I have used this NPC many scenes and apparently this scene has nothing different from the others, I'm a bit lost on why is behaving this way all of a sudden.

Console has no warnings or errors.

Always thanks for the support!
Best,
Flavio

Comments

  • Sorry, but I'm not clear on the underlying issue. By "falls behind", do you mean that the Player and the NPC are drawn in the wrong order?

    When two characters are in the same Sorting Map region, their sprite children will be "pushed" slightly in the Z-axis to correct their display. Check that they're in the same region, their Sorting Groups both have the same Sorting Order value, and that the Z-axis offsetting is occuring.

    Bear in mind, though, that AC is no longer necessary for character sorting. Unity's Graphic settings now let you customise the Transparency Sort Axis. Setting this to (0,1,0) causes sprites to be sorted according to their vertical position - letting you uncheck the Sorting Map's Affect character sorting? option, so that the Order In Layer can remain unaffected at runtime.

  • Sorry for being unclear.

    Yes by "falls behind" I meant the player is displayed below the NPC, even if the NPC is farer - wrong order - as you said.

    I did run the tests and checks you suggested and the Sorting Map's Affect character sorting? unchecked didn't work. - and I also tried all the possible combination of settings and seemed nothing worked.

    But finally, I had a breakthrough Setting the Sorting Group of the NPC at -1 and setting the Main player Sorting Group at 0. [Keeping the Affect character sorting? checked]

    Thanks for your fundamental support!
    Best,
    Flavio

  • *** update, my bad my solution didn't work, just made the same issue but the other way around, so the player is always on top. I don't have solutions.

    Sorry for the previous information. It was wrong.

  • But finally, I had a breakthrough Setting the Sorting Group of the NPC at -1 and setting the Main player Sorting Group at 0. [Keeping the Affect character sorting? checked]

    With the option checked, AC should be updating Sorting Order values at runtime - setting the values manually ought to make no difference.

    Could you share images of the objects/windows involved?

    The other approach is generally easier to manage, once set up, though. If you'd like to give that another go, share images again of the setup and we can see what's wrong.

  • Hello there,

    Thanks again for the suggestion and the awesome support! It is immensely appreciated.

    I took a radical approach because the situation was getting too complicated for me.

    I deleted the whole scene and re-built it from scratch.
    Everything now works as the other scenes, the player and the NPC are displayed in the correct order anytime, after teleport, after move to point and if the NPC is set to follow.

    The old scene must have had some inherited issue nested somewhere that was causing the problem to arise. Which at this point I will never know, there was nothing different in this scene from the other. I am clueless.

    To the sake of completeness I will write down how's the current setting that works for me:

    Sorting Map:
    Affect Character sorting? checked
    Affect sprite's: Order in Layer

    NPC sorting group 1 and Player sorting group 0 [but if I got it right, this last info is meaningless if the Affect Character sorting? is on.]

    Best Regards,
    Flavio

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.