- 수정됨
z fighting with multiple prefabs
I have a prefab with a SkeletonAnimation component attached to it, with AnimationName set, and Loop set to true. If I have only one of those prefabs sitting in my scene it plays fine. However if I have multiple instances of that prefab there seems to be a lot of z-fighting going on. Does anyone know what could be the cause of this?
The below link shows my scene indicating the problem. I have five instances of the prefab in the scene with z fighting occurring https://gfycat.com/SomeCircularBoto
If your skeleton is drawing from multiple textures, there is a known bug in Unity 5.6 and above where Unity's sorting system sees common materials between instances and tries to batch them, but breaks the sorting in the process.
The fix in that case is to add a Sorting Group
component to each instance.
A fix that has better performance scaling is to make sure your skeleton is only using one texture. This also makes it so that the Sorting Group is not required.
If this isn't your problem, can you describe your setup more?
Technically, this is not zfighting, as z-fighting is specifically a depth buffer accuracy problem: https://en.wikipedia.org/wiki/Z-fighting
Adding the sorting group fixed it, thanks.
Good to hear!
Best of luck on your game!