Unity Sprite Layering - Y Sorting, Sorting Layer and Order in Layer

Поделиться
HTML-код
  • Опубликовано: 3 янв 2025

Комментарии • 115

  • @simmzzzz
    @simmzzzz 2 года назад +62

    For those with multiple sprite orders for their characters (i.e. body, clothes, hat, etc.), you can add a "Sorting Group" to the parent to keep them all together.
    It took me a full day to figure this out, and no tutorials mention it.

    • @wolfmobile7128
      @wolfmobile7128 Год назад

      Thank you!

    • @Bladeshifter20
      @Bladeshifter20 9 месяцев назад +1

      Thanks for mentioning this! Been googling "2d layers + clothes + ordering" for a bit now!

  • @mantavisions2362
    @mantavisions2362 2 года назад +52

    For those using URP, Transparency Sort Axis can be found on the Renderer Asset, not in the graphics settings.

  • @izeckx
    @izeckx 3 года назад +13

    Thank you for this. I had been racking my brain to do this, but every method I found was years old. I knew there had to be a better and newer method.

    • @ShootingDux
      @ShootingDux  3 года назад +1

      No problem, glad it helped.

  • @Sonic1305
    @Sonic1305 4 месяца назад

    I struggled since days trying to figure out how to handle the sorting order by code and you just show me a way the engine does it itself. I thank you for this, from the bottom of my heart!

  • @MAXmillium
    @MAXmillium 11 месяцев назад

    This is magic!
    Small correction @ 2:50 , x and z are 0. and y set to 1.

  • @AN4RCHID
    @AN4RCHID 2 года назад +8

    Thanks man, straight to the point and exactly what I was looking for. Cheers!

  • @dailyshadow
    @dailyshadow 6 месяцев назад

    Wow this is amazing. I was doing this the really annoying hard way where I was in code manually changing stuff. And here Unity literally gives you this for free.

  • @DoZer11-l8e
    @DoZer11-l8e 2 месяца назад

    It was very very helpful! I was just making new CameraManager for this feature from ZERO, and noe I don't have to waste time anymore!!!

  • @wearingorbentertainment716
    @wearingorbentertainment716 Год назад

    thanks for the vid

  • @JackieCodes
    @JackieCodes 3 года назад +1

    Thank you, I didn't realize that you had to manually change the sprite sort point to pivot.

    • @ShootingDux
      @ShootingDux  3 года назад

      No problem, it's pretty tricky. I've spent a lot of time on this myself.

  • @megaswords1142
    @megaswords1142 3 года назад +2

    Good and fast, great tutorial man, this is what i needed

    • @ShootingDux
      @ShootingDux  3 года назад +1

      Thanks for the comment. It's always great to hear that someone got something from one of my videos. Really encouraging to see them helping people.

  • @Telles0808
    @Telles0808 Год назад

    always come back, like a reminder, I should do my own videos like you did, so, I can recur for it to remember these settings 🤦‍♀

  • @EvilP
    @EvilP 8 месяцев назад

    Absolutely a lifesaver tutorial

  • @vizion4724
    @vizion4724 2 года назад +29

    Thanks for the help. But I just have question for anyone who may know, does this type of y sorting not work on tilesets? Because I could make this work on individual sprites, but not on tiles from a tileset.
    Edit: I figured it out. If you want to sort tilesets correctly you have to do everything mentioned in the video but specifically for tilesets you have to go under the component "Tilemap Renderer" -> "Mode" and then change from "Chunk" to "Individual". Hope this helps someone

    • @MrKethurk97
      @MrKethurk97 2 года назад +2

      Lifesaving, bless u!

    • @ShootingDux
      @ShootingDux  2 года назад +2

      Very useful info. Thanks for sharing on here and glad the video was useful.

    • @xxMpEGxx
      @xxMpEGxx 2 года назад

      Youre a lifesaver

    • @epohx7252
      @epohx7252 Год назад +1

      thanks so much!!!! i looked for this for HOURS!!

    • @aidantilanus
      @aidantilanus Год назад +1

      i have trees as tiles but the are 2 tile high that does not work

  • @christinaVennegerts
    @christinaVennegerts 2 года назад +1

    Very good video - short and to the point. Thanks!

    • @ShootingDux
      @ShootingDux  2 года назад +1

      Thanks, glad it was useful.

  • @patitowgames
    @patitowgames 2 года назад +2

    Incredible tutorial, helped a lot, thank you so much!!

    • @ShootingDux
      @ShootingDux  2 года назад +1

      You're very welcome, I'm happy it helped.

  • @wcysitp
    @wcysitp 2 года назад +1

    Thank u, it was useful for me too. Great job!

  • @iwoMalki
    @iwoMalki 2 года назад +1

    Great video man! Thanks!

  • @SkycrO_Ou
    @SkycrO_Ou 3 года назад +1

    Thank you very much for this video! It was very useful for me.

    • @ShootingDux
      @ShootingDux  3 года назад

      Thank you. I'm glad it was helpful.

  • @Blin_Blinskii
    @Blin_Blinskii 3 года назад +1

    Oh, thank you so much! Deserved like and subscription^^

    • @ShootingDux
      @ShootingDux  3 года назад

      Thank you. Really glad to see people getting something useful from the video.

  • @katapultti
    @katapultti 3 года назад +1

    Thanks mate! You really helped me

    • @ShootingDux
      @ShootingDux  3 года назад +1

      Glad it helped. Great to hear of someone getting something from the video.

  • @styxrakash4639
    @styxrakash4639 Год назад

    Great info man

  • @level1gg
    @level1gg 3 года назад +3

    Life saver!

  • @eddie.z
    @eddie.z 3 года назад +1

    A but late but this is a great explanation and video.

    • @ShootingDux
      @ShootingDux  3 года назад

      Thanks, it always amazes me how often I have to go back and refresh my memories on this.

  • @DamiiPeralta
    @DamiiPeralta 2 года назад +1

    Thanks !!! you are great !

  • @renderfeynolt
    @renderfeynolt 2 года назад +1

    I was loosing my mind, tnx

  • @eellauu
    @eellauu 2 месяца назад

    That kinda works, but what it does is it sorts by center, which is not always accurate. It should sort by the bottom of the sprite. I guess the only way to do that is to modify sprite's pivot point? But that's a weird solution, what if I would like to rotate that sprite afterwards and it would look really weird?

  • @kkuran371
    @kkuran371 Год назад +1

    I want to put a plant on a table, but the plant is always drawn behind. If I put it on a higher layer my player just phases through it. Help?

  • @hanni6383
    @hanni6383 26 дней назад

    What can i do?
    My player have a height of 2 tiles. If i go behind a tree with a lets say 6 tiles height i just cant sorting the bottem tile wiith the colloder part. How can i solting the second tile, the tile with the tree trunk?

  • @farmersfigs
    @farmersfigs 2 года назад +2

    Hey great video, wee question, do you know how it would work if your characters are built up from multiple sprites, for example if your characters body, head, arms and legs are all attached to a parent game object?

    • @ShootingDux
      @ShootingDux  2 года назад +1

      I think it should all work the same. Just make sure they are all on the same layer. For the character in the video I had different attachments which worked (gun for example).
      Are you having a particular issue?

    • @farmersfigs
      @farmersfigs 2 года назад

      @@ShootingDux That's great man, wasn't having any particular issue was just a thought after watching your video. Liked and subscribed mate

  • @cocoduck7745
    @cocoduck7745 2 года назад +1

    it worked before but it doesn't work with the 2021 version when I added URP to my project. Is there any solution for that?

    • @ShootingDux
      @ShootingDux  2 года назад

      I tried adding URP to my project and it stopped working. To get it working again I had to update the renderer asset. In there I set the Transparency Sort Mode to "Custom Axis" and the "Transparency Sort Axis" to X:0, Y:1, Z:0.
      If you can't find the asset then go to Project Settings > Graphics and the URP Asset will be set in the "Scriptable Render Pipeline Settings" field. If you click on that then it should select in the project tab and display the info in the inspector. The Renderer List should be in there, I have a 2D Renderer in there as it's a 2D project. That's the asset you'll need to update. The transparency sort mode, etc. are part of the General section.
      I think this should solve the problem. It sorted it for me adding URP and I think I was using version 2021 when I tested this.

    • @cocoduck7745
      @cocoduck7745 2 года назад

      @@ShootingDux yeah it worked thanks man👍

    • @ShootingDux
      @ShootingDux  2 года назад +1

      @@cocoduck7745 awesome, glad it worked.

  • @RaulfGameStudio
    @RaulfGameStudio 11 месяцев назад

    How do i do if i have multiple assets being instantiated but because of the collinder they get one on top of the other, but i'd like them to be side by side also in the Z, but as a 2d game would order in layer be enough? i have changed the orders when clonning them but no deal

  • @DanneTheMan1
    @DanneTheMan1 3 года назад +3

    Hey man great video!... I'm having an issue though. I'm creating an 2d game atm and I have objects like trees and streetlights that I want my character to be able to go under. But I can either make the character over the whole object or under it and It needs to be half, is that makes sense. xD
    Example:
    If the object is at 0 and the character goes to y1 and is now under the tree. If I put the character to y-1 the root of the tree now appears to be over the character.
    The only solution I can think of is I need to make the sprite into two parts and put it into two different sorting layers. But it didn't work that great... Is there any other solution to this?

    • @CapedNinja
      @CapedNinja 2 года назад +1

      I believe you can solve that by setting the pivot point of each sprite to where it touches the ground, so your character's feet, the bottom of the tree trunk, the base of the streetlights, and so on. You can set a custom pivot point for each sprite by opening up its sprite import settings and going into the Sprite Editor menu.
      If done correctly, when you select the object in the Scene window with the Move Tool active, you should see the green and red arrows coming from the bottom of the object where you set the custom pivot point.

    • @ShootingDux
      @ShootingDux  2 года назад

      Thanks for helping out.

  • @liamaugust9070
    @liamaugust9070 10 месяцев назад

    When I use Sort Axis it only works when I put the objects exactly in the middle otherwise when the objects are on the top half, I move over it, when the objects are on the bottom half I move under it can someone please help

  • @joexscript7046
    @joexscript7046 2 года назад +1

    Me salvaste la viva men xD

  • @urkskn8842
    @urkskn8842 2 года назад

    Thanks for help!

    • @ShootingDux
      @ShootingDux  2 года назад +1

      You're welcome. Thank you for the comment, it's always great to hear when a video is helpful.

  • @chrisbee1984
    @chrisbee1984 2 года назад

    Thanks for that

  • @ismailyou
    @ismailyou Год назад

    Thank you.

  • @theholycity7498
    @theholycity7498 3 года назад +1

    I do this and it makes my object sort from center even if I choose pivot and set the pivot where I want the sorting to happen so the layering changes right in the middle of my player and I can't figure out how to fix it

    • @ShootingDux
      @ShootingDux  3 года назад

      Even after setting the pivot point it's maybe worth checking where the pivot point is on the sprite. You can get this from the inspector when you select the sprite.

    • @ravenempty3562
      @ravenempty3562 2 месяца назад

      answer in russian
      после 3 лет я наконец нашел ответ на твой вопрос :D Нужно у каждого объекта в Sprite Renderer выставить "Sprite sort point" значение "Pivot"

  • @dinosora6518
    @dinosora6518 2 года назад +1

    Hello this is a great video, though I have a small question, I am making a 2D game and was trying to make my character go behind/Infront of a tree and it mostly works, the only issue is, is that it only works for the top half of the tree, I made sure that I changed the y value in graphics, made a new sorting layer, changed my character to pivot, any ideas about what I am doing wrong? Thanks!

    • @ShootingDux
      @ShootingDux  2 года назад +2

      It's really hard to know without seeing the project really... what I would guess at is the pivot point of the tree graphic, my guess is that the pivot for the tree is in the middle or on top instead of at the base of the tree. I think that might cause the issue. Hopefully that helps, and good luck with your project.

    • @dinosora6518
      @dinosora6518 2 года назад

      @@ShootingDux thank you so much!! This was exactly the issue! Can’t believe I forgot to check 😅 thank you for responding to my question!

    • @FCO1988
      @FCO1988 Год назад

      @@ShootingDux thank you! This was what I needed, I was already going crazy haha

  • @MissMagic23
    @MissMagic23 2 года назад +1

    It dosent work for me, the player gets behind from other objects almost when it gets in the middle.

    • @ShootingDux
      @ShootingDux  2 года назад

      It's hard to say exactly what the issue is but my guess is that the origin point of the player is off or else the other objects. I sometimes get little issues like this when everything is set correctly but the object has an extra parent container that is offset

    • @ravenempty3562
      @ravenempty3562 2 месяца назад

      answer in russian
      после 3 лет я наконец нашел ответ на твой вопрос :D Нужно у каждого объекта в Sprite Renderer выставить "Sprite sort point" значение "Pivot"

  • @이석호-q5y
    @이석호-q5y 3 года назад +1

    wow good great tip

  • @matgata1040
    @matgata1040 Год назад

    THANKS!!!

  • @C0rf33
    @C0rf33 2 года назад

    Thanks u so much

    • @ShootingDux
      @ShootingDux  2 года назад

      No problem. Love to see this video helping people.

  • @kt249
    @kt249 9 месяцев назад

    thanks a lot

  • @GalaxyHellsGamer
    @GalaxyHellsGamer 10 месяцев назад

    TYSM

  • @Jaypordy
    @Jaypordy 3 года назад

    Sorting stops once the pipeline is changed back to URP. Any fix for this?

    • @ShootingDux
      @ShootingDux  3 года назад

      I hadn't seen this happen and don't know a fix. Hopefully you've found a solution by now?

    • @Jaypordy
      @Jaypordy 3 года назад +2

      @@ShootingDux Yes. Quite simple. The very same options are available in the URP pipeline asset. You can find it in the inspector.

  • @Youifmain
    @Youifmain 10 месяцев назад

    it doesnt work with urp?

  • @dieselwiesel316
    @dieselwiesel316 2 года назад

    Do you maybe know a reason why it doesnt work? I've watched atleast 5 different videos, all of them nearly telling me the same steps on how to do this and everytime it doesnt work

    • @ShootingDux
      @ShootingDux  2 года назад

      What version of Unity are you using? And are you using the URP?

    • @dieselwiesel316
      @dieselwiesel316 2 года назад

      @@ShootingDux im using 2021.3 and yes im using URP.

    • @ShootingDux
      @ShootingDux  2 года назад

      I tried adding URP to my project and it stopped working. To get it working again I had to update the renderer asset. In there I set the Transparency Sort Mode to "Custom Axis" and the "Transparency Sort Axis" to X:0, Y:1, Z:0.
      If you can't find the asset then go to Project Settings > Graphics and the URP Asset will be set in the "Scriptable Render Pipeline Settings" field. If you click on that then it should select in the project tab and display the info in the inspector. The Renderer List should be in there, I have a 2D Renderer in there as it's a 2D project. That's the asset you'll need to update. The transparency sort mode, etc. are part of the General section.
      This got the sorting working for me. I'm guessing that's going to solve the problem. Hopefully.

  • @Nebeneinkommen
    @Nebeneinkommen 3 года назад +1

    thx

    • @ShootingDux
      @ShootingDux  3 года назад

      Glad it was helpful. Hopefully some of my other videos are useful too.

  • @redinternet9893
    @redinternet9893 2 года назад

    it doesn't work in tilemap

  • @albikroalperen
    @albikroalperen 2 года назад

    Y sorting doesnt work

  • @mactram7293
    @mactram7293 Месяц назад

    tk

  • @ryan_nvv
    @ryan_nvv 3 года назад +1

    Thank you so much!, it's very helpful

    • @ShootingDux
      @ShootingDux  3 года назад

      Awesome. It’s always great to hear that someone is finding this video helpful.

  • @upsilondiesbackwards
    @upsilondiesbackwards 3 года назад

    Thank you so much, this has helped me alot

  • @EmirKaanOgsarim
    @EmirKaanOgsarim 11 месяцев назад

    Ty sir!