Forum rules - please read before posting.

How to set a NPC with only 2 direction animations and how to set it's sort order?

edited May 7 in Technical Q&A

Hi all,

I followed the youtube 2d tutorial and try to add an NPC as exercise. I found a lot animations on unity assetstore have only two directions. So I choosed one from here: https://assetstore.unity.com/packages/2d/characters/isometric-character-dog-302332

Now, I got two questions:

  1. How can I set the NPC with only front and back animations?
    https://www.codehamster.com/wp-content/uploads/2025/05/2025-05-07_06-01-04.webp

  2. And how to set the NPC sort layer of the NPC?
    I can not let the NPC set on the park bench, it always behind the bench. Though I have set the "pivot" on "Sprite Sort sorting" and also added the sorting group.
    https://www.codehamster.com/wp-content/uploads/2025/05/2025-05-07_05-45-19.webp

Thanks very much for the help!

Conny

Comments

  • In AC's terminology, "Up" and "Down" are what it calls "Back" and "Front". You can check the Up and Down, and uncheck the others, to have it only face those directions.

    However, your character uses the "Sprites Unity Complex" character animation - not the "Sprites Unity" animation option that the video tutorial covers.

    With "Sprites Unity", animations are played automatically based on naming convention. So "Idle_D" for down/front etc.

    With "Sprites Unity Complex", animations are instead played with Animator transitions based on parameter values - the more usual way of working with animation in Unity. AC will update parameter values automatically.

    For example, the "Direction integer" - if set - will be set to the character's facing direction represented as a single digit. The Manual's "Character animation (Sprites Unity Complex)" chapter covers this in more detail, but this value will be 0 for Down/Front and 3 for Up/Back.

  • edited May 7

    Hi @ChrisIceBox Thanks so much for the clear answer of the question. o:)

    But can you also take a look for my second question: why my dog is always behind the park bench? :'(

    https://www.codehamster.com/wp-content/uploads/2025/05/2025-05-07_17-14-28-1.webp

    I use the "character wizard" created the NPC (dog), and try to put it on the "ParkBench" , however, it doesn't work, it always behind the bench...

    What I have done is:

    1. Dog Sprite:

      • modify the Sprite Rendere component on Dog Sprite , set the Sprite sort point to Pivot
      • Add the Sorting Group component to Dog Sprite
    2. Global Settings for Unity 6 Urp.

      • Find the URP setting file: Assets-> Settings ->Renderer2D.asset
      • Set the Transparency Sort Axis to (0,1,0)
      • You said in the video to use a script, but it is not necessary, the unity 6 URP still has the setting, it just moved the place, please see here. :smile:

    https://www.codehamster.com/wp-content/uploads/2025/05/2025-05-07_17-25-37.webp

  • @ChrisIceBox I think, I found the problem, I should set the sprite center of the dog to the "bottom center" in sprite Editor. However, the Dog Sprite is made a lot of images. I changed only the first slice pivot.

    So, the solution will be change all pivot of the slided images to bottom center... But I have no idea how to set one time all the pivot of the slided images to bottom center... I know this is not the topic of AC... :'( But hope you can give me some suggestions.

  • Again, it's me, problem solved. You just need to re-slice the sprite and set it pivot at bottom. The only problem is the old animation will broken... :'(

    Animation in unity is a nightmare... :s

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.