Forum rules - please read before posting.

Sorting layer issue with Player and NPC

Hi,

I have now created my player and NPC's using a kind of mechanism approach. were each part of the character is a separate child of a main child within the root object  with a separate sorting number (see link to screenshot). However, I am running into frustration where certain rooms objects interfere with the layers within the characters layers (see link to screenshot), is there a way to stop this? And have the root object have a specific sorting layer that tits child objects don't interferer with etc?


Thanks

Comments

  • I'm not clear what's going on in your screenshot - are there two characters in the same place?

    As you have Offset original order? checked in your FollowSortingMap component, you should find that e.g. "Head" always has an order of 2 greater than "Garland".  You will need to make sure, then, that the layer numbers in your SortingMap are spread out wide enough to encompass the offsets.
  • Hi,

    I have three root objects (WALK_D, WALK_U, and a head and body for Right) within my Player object.

    See the video at this link to further explain this:

  • edited January 2016
    Your first post was about the character intefering with scene objects - are you now saying the problem is instead with child objects being enabled when they shouldn't be?

    Screenshots and videos are helpful, but context is always needed - please explain as clearly as you can what exactly the problem is.
  • No, apologies, it is elements of my character interfering with other objects in my scene. I think the best thing I need to do is to have the root object only being affected by objects sorting layers in the scene, and the child objects layer order not affecting anything but other character child objects.

    how do i ensure this is the case?
  • Uncheck Also affect children? on your FollowSortingMap, and then set the SortingMap in your scene to control Sorting Layer, not Order In Layer.
  • Thanks, and then do i have to manually enter my layer number for each sorting map position or can these be blank?
  • Plus, would you recommend having the head of my characters starting at 5 in their sorting layer or 1? Or does it not matter once I apply the above?
  • And, apologies, but do i leave offset original order on or off?
  • You'll need to instead enter layer names, not numbers, into your Sorting Map - after creating and applying enough layers into your scene: e.g. "FarBackground", "MidBackground", "Normal", "Foreground".

    The relative order between the child objects shouldn't be affected - though I think I was wrong about unchecking Also affect children? - you want that on so that all sprites are placed on the same layer (but still have different orders within that layer).  And Offset original order should be off, I believe.
  • Thanks,

    I generally just have one bg and a foreground with different objects in my scene that need to be in front or behind my characters, so are these the layers i need to enter in to the layer names? 
  • Sorry, I am finding this Sorting Map issue very confusing, it was a lot easier using Order in layer?
  • ie if i have a sofa in the middle of the scene, and i need the player to walk behind it and in front of it, but i also want my character to get bigger at the bottom of the scene and smaller at the top...
  • Order in layer is the default, because it's the easiest to use.  Since you want complex character animation with multiple layers, the knock-on effect is that it's harder to set your scene up.

    The layer names I gave were just examples - the principle's stil the same as numbers, only you're using names instead.  You could even name your layers as numbers, e.g. "1", "2", etc.

    Your sofa example is exactly what SortingMaps are for - once you've set it up correctly, that's how it'll behave.
  • Just to clarify, the name of the layers in the sorting map must be names exactly the same as the layers in my scene? Ie 'sofa' in scene is the name given to the layer in the sorting map?
  • No - you'd want the SortingMap to use different layer names that go in between your static scene objects, because characters that follow it will be on the layers defined by the Sorting Map, and you don't want them to conflict with your scene sprites.

    For a simple room with a sofa in the middle, you could use something like:

    Background (Assigned to a scene sprite)
    ->
    MidBackground (On the sorting map, so assigned automatically to characters)
    ->
    Sofa (Assigned to a scene sprite)
    ->
    MidForeground (On the sorting map, so assigned automatically to characters)
    ->
    Foreground (Assigned to a scene sprite, if appropriate)

    The reason I suggested using number strings instead of e.g. "Sofa" is so that you can intuitively re-use them for different scenes.
  • Sorry this isn't making any sense and whatever I do, my characters interfere incorrectly with my scene objects.
  • How do you assign to a scene Sprite? I just have one background and objects in the scene. And a very 'in front ' foreground
  • To assign a layer name to a scene sprite, I'm referring to the Sprite Renderer component, not the sprite asset file - just change the Sorting Layer value.

    Whether you use the Layer Name or Order Number to control your Sorting Map, the principle is the same.  The Sorting Map will change the layer/order or any sprite that has a Follow Sorting Map component according to their position in the scene.  Sprites that do not have a FSM will not be affected.  You can open up the 2D Demo scene to see how multiple stationary objects are placed in a scene so that the Player can move around them.
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.