I am working on a small 3D tank game project where I want the walls to have a lower opacity every time there's a tank (player) behind them.
I tried several different ways using the position of the walls, trigonometry and bounding boxes, but nothing seems to work and I need help.
Here's the problem!
In the top-down view, I want the wall to get transparent when the player is behind (higher in the Y axis) the wall and within points A and B, which would be the width of a rectangle encapsulating the wall.
However, I want the wall to be fully opaque when the player is in front (below in the Y axis) of the wall.
So far, so good! The problem is that I want to avoid this problem, where if the player is in front of the wall but higher than its origin point in the Y axis, the wall will go transparent.
The opposite should also be avoided when the wall goes remains opaque even though the player is behind it because they're below the wall's origin point.
This would work very simply if all the walls were at right angles, but I want to be able to have a full range of rotation for them and make it work.
Any ideas on how I could approach this problem and achieve the desired result? I tried many different things with varying levels of success, but never fully got there.