Forum rules - please read before posting.

Sorting Maps And Their Interaction With Moving NPCs

I'm currently in the process of making a 2D game that has a secondary character that always follows the main character around the environment(think similar behaviour to Max from Sam and Max) however I am encountering issues with sorting maps.

Is there a way to get a follow sorting map to take into account location of the Player and factor it into it's calculation? Ensuring the NPC renders correctly relative the Player's location

So for example if my NPC is above(a y value greater than the Player) the Player(thus should render behind) it decrements the sorting map value by 1 or if the NPC is below(y value lower than the Player) increments the sorting map value by 1 rendering them in front of the player.

Comments

  • Welcome to the community, @Xoryn.

    This is for when two characters are within the same Sorting Map region, yes?  If they're in separate regions, the oders will be different.

    Within the same region, AC should shift the position of the GameObject with the FollowSortingMap ever so slightly to/from the camera to correct the display of two sprites with the same Sorting Order.  Is this not happening?  You should find that either the NPC or the Player sprite has a non-zero Y position when they're in the same region.
  • Screenshot of my game

    The player controls the small robot character show at the bottom. The bigger character(played by Elaine currently) is my NPC that follows the robot around. Both characters follow the default sorting map for the room.

    If she was a traditional stationary NPC my sorting map values could account for her just like any other object in the scene and correctly render the robot in front or behind her.

    Unfortunately due to her movements round the room following the robot the sorting map can't take this into account and will not give the desired layering of sprites. In the screenshot shown you can see the robot is in front of her but is being rendered behind her. Is there a way that I can avoid this or take into account characters when setting a sorting value for my Player character of my NPC?

  • I understand your issue, but my first reply still applies: please check to see if the sprite positions change.  You must ensure that your sprite child transforms are originally at the (0,0,0) position, and that they both have the FollowSortingMap component.
  • I've realised my issue while checking what you suggested. The original starting sorting values did not match on either of the characters. So just complete user error on my part!

    Thanks for taking the time to reply and help out, Chris. AC is a great asset, your support and effort with this asset is pretty much unmatched. Apologies for misunderstanding your first post
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.