So I did some browsing the BA history to see if anyone asked this before and I found that it’s been asked multiple times but either has one incorrect reply or no replies.
So please forgive me for the redundant question
I have walls in game that are set to an animated Alpha Blend so my camera can see through them when they are in the way.
It works great except that even when the transparency is set to 100 opaque they do this clipping thing. The wall around the outside of the level clips through all my terrain which is separate objects that also use an alpha blend.
all the separate ruins objects use the same material which is alpha blend and the wall around the outside has a separate material but it is all alpha blend.
I strongly suggest to avoid putting everything on alpha blend.
Alpha blend bypasses the Z-Buffer processing which adds a lot of workload on the rendering. Alpha blend sorts the faces on Z-order. As you can imaging sorting a lot of faces can become very slow. Therefore it is not recommended to use that on a lot of faces.
While you might accept this workload on your game you should also consider that sorting does not always create the results you are expecting. Sometimes there even is no drawing order e.g. when faces overlap, or even more worse when faces intersect.
I think the BGE renderer sorts the objects first to save sorting time. So this might happen in your case … you got the incorrect sorting order which draws the object from back later then the objects in front of it.
How could that ever be sorted with the objects inside?
What is a solution?
A) avoid alpha as much as you can
B) apply alpha materials only on “compact” objects with no intersections or overlapping to other alpha objects
C) never intersect alpha faces
D) avoid overlapping alpha faces
Other design
In you case I recommend a more complicated system. In the end it will be much more render efficient and avoids these problems:
Have each object that should turn semi-transparent twice.
Sounds strange? yes it is.
A) You need one full opaque object that is what you usually have in your game. No need to worry about transparency.
B)Have a second object with alpha (that looks exactly as the opaque one). When you want the first object become semi-transparent you replace it with the second on. When it goes back to opaque … replace it back.
Additional this has the advantage that you can add the otherwise invisible parts of the walls (inside, button etc.) on the semi-transparent version only.
You will spend more time on modelling and you keep more objects in memory, but I think it is worth.