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.
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!
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.
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
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?
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?
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?
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?
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.
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
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?
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.
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
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
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.
answer in russian после 3 лет я наконец нашел ответ на твой вопрос :D Нужно у каждого объекта в Sprite Renderer выставить "Sprite sort point" значение "Pivot"
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!
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.
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
answer in russian после 3 лет я наконец нашел ответ на твой вопрос :D Нужно у каждого объекта в Sprite Renderer выставить "Sprite sort point" значение "Pivot"
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
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.
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.
Thank you!
Thanks for mentioning this! Been googling "2d layers + clothes + ordering" for a bit now!
For those using URP, Transparency Sort Axis can be found on the Renderer Asset, not in the graphics settings.
I love you
Thank you
This comment needs to be pinned.
thank you so much
What is that I can't find it
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.
No problem, glad it helped.
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!
This is magic!
Small correction @ 2:50 , x and z are 0. and y set to 1.
Thanks man, straight to the point and exactly what I was looking for. Cheers!
Glad it was useful!
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.
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!!!
thanks for the vid
Thank you, I didn't realize that you had to manually change the sprite sort point to pivot.
No problem, it's pretty tricky. I've spent a lot of time on this myself.
Good and fast, great tutorial man, this is what i needed
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.
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 🤦♀
Absolutely a lifesaver tutorial
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
Lifesaving, bless u!
Very useful info. Thanks for sharing on here and glad the video was useful.
Youre a lifesaver
thanks so much!!!! i looked for this for HOURS!!
i have trees as tiles but the are 2 tile high that does not work
Very good video - short and to the point. Thanks!
Thanks, glad it was useful.
Incredible tutorial, helped a lot, thank you so much!!
You're very welcome, I'm happy it helped.
Thank u, it was useful for me too. Great job!
Glad it helped!
Great video man! Thanks!
Thank you, glad it helped.
Thank you very much for this video! It was very useful for me.
Thank you. I'm glad it was helpful.
Oh, thank you so much! Deserved like and subscription^^
Thank you. Really glad to see people getting something useful from the video.
Thanks mate! You really helped me
Glad it helped. Great to hear of someone getting something from the video.
Great info man
Thank you, glad it was useful.
Life saver!
Glad it helped!
A but late but this is a great explanation and video.
Thanks, it always amazes me how often I have to go back and refresh my memories on this.
Thanks !!! you are great !
Thank you. Glad this helped
I was loosing my mind, tnx
Happy to help.
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?
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?
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?
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?
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?
@@ShootingDux That's great man, wasn't having any particular issue was just a thought after watching your video. Liked and subscribed mate
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?
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.
@@ShootingDux yeah it worked thanks man👍
@@cocoduck7745 awesome, glad it worked.
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
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?
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.
Thanks for helping out.
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
Me salvaste la viva men xD
Glad it helped.
Thanks for help!
You're welcome. Thank you for the comment, it's always great to hear when a video is helpful.
Thanks for that
Thank you.
You're welcome!
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
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.
answer in russian
после 3 лет я наконец нашел ответ на твой вопрос :D Нужно у каждого объекта в Sprite Renderer выставить "Sprite sort point" значение "Pivot"
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!
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.
@@ShootingDux thank you so much!! This was exactly the issue! Can’t believe I forgot to check 😅 thank you for responding to my question!
@@ShootingDux thank you! This was what I needed, I was already going crazy haha
It dosent work for me, the player gets behind from other objects almost when it gets in the middle.
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
answer in russian
после 3 лет я наконец нашел ответ на твой вопрос :D Нужно у каждого объекта в Sprite Renderer выставить "Sprite sort point" значение "Pivot"
wow good great tip
Thanks
THANKS!!!
Thanks u so much
No problem. Love to see this video helping people.
thanks a lot
TYSM
Sorting stops once the pipeline is changed back to URP. Any fix for this?
I hadn't seen this happen and don't know a fix. Hopefully you've found a solution by now?
@@ShootingDux Yes. Quite simple. The very same options are available in the URP pipeline asset. You can find it in the inspector.
it doesnt work with urp?
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
What version of Unity are you using? And are you using the URP?
@@ShootingDux im using 2021.3 and yes im using URP.
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.
thx
Glad it was helpful. Hopefully some of my other videos are useful too.
it doesn't work in tilemap
Y sorting doesnt work
tk
Thank you so much!, it's very helpful
Awesome. It’s always great to hear that someone is finding this video helpful.
Thank you so much, this has helped me alot
Ty sir!