Deactive sprites that are behind another sprites ?

199462-1.png

The problem is that the camera still renders those characters that are behind another characters , how can I fix it? I would appreciate any ideas.

To be honest, I really don’t think you need to worry about this. If in doubt, try using profiling. It’s a fantastic tool but take an hour to get to know enough to answer your question. There was a really good session at Unite Now 2020, which is available on YouTube

If you have some really busy code to run on all sprites then you could try using a raycast from the camera. Put that code on your prefab and you can use it to conditionally run the code.

Unity’s Official way of doing this, however, is Window > Renderer > Occlusion Culling. You can read more about it here. However, it’s best for things like walls and other static environment objects. There is an overhead (memory and CPU) that makes it questionable for dynamic objects like Players or NPCs.

Don’t try and use OnBecameInvisible() or renderer.isVisible because they won’t tell you if something is occluded. If it’s in the scene and in the viewport, it’s visible to the camera, whether occluded or not.

May I ask what problem you are trying to solve?

Is it that the extra sprites appear? Or that they can be clicked? Or perhaps a performance issue? Not really clear what your concern is.

If you create the sprites, they are bound to appear but their appearance seems fine, in that the rear ones are occluded…