sprite changes sort order randomly issue

In the example clip, you can see when a bunch of sprites clump together, they start to pop in front and behind each other. They are all on the same sorting layer. It’s my understanding that each sprite is given a hidden ID on instantiation which determines their order in the layer and doesn’t change. So what’s happening here?

Video clip: Imgur: The magic of the Internet

its not a hidden id, its labeled as order in layer in the inspector

this happens when all sprites have the same order, you should set the order you want them to be in

I mean if two sprites have the same sorting layer and order, the engine will randomly select one to be sorted above the other based on a hidden ID that doesn’t change. If I’m spawning many instances of the same object, it isn’t really feasible to give each one a different order in their respective sorting layer. I’ve never seen that done, is that common practice?

yes, you should give different orders in layer to instantiated objects if they overlap, not doing so will produce the glitching displayed in your video. How should unity know which object sorts above the other if you dont tell it yourself

PSA - For those having sorting issues with 2d sprites in 3D URP, the problem for me was that the Transparent Sorting Axis was reset in my project, and the option is HIDDEN in the Graphics settings. This solved the issue at the root level:

https://en.esotericsoftware.com/for…t-correct-in-urp-forwarded-rendering-unity/14