How can I hide everything behind line of site in a top down game
I'm creating a top down isometric game for my first attempt, it's a recreation of a childhood game I played for hours as a kid.
I'm just unsure how I can hide everything that is blocked by line of site, here's an example
Where my character is standing, I shouldn't be able to see behind that wall to the characters right, I'm just unsure how I can accomplish this. Thanks.
asked Nov 06 '18 at 07:11 AM in C++ Programming
The most straightforward way I can imagine is doing raycast checks for player visibility continuously, then having an opacity parameter in the object's material, which you then feed the result of the visibility check, basically.
This requires work on every object that should be able to become transparent though. I'm not sure an easier solution exists though.
answered Nov 06 '18 at 10:04 AM
there are many ways to implement this.
In case you want to hide mesh completely - make multiline or multisphere trace from camera to character, and set visible = false for everything this trace returns. Then store it in some array and make visible when it is not overlapped anymore. Remember that everything you want to hide must have collision response for trace channel set to "overlap" to make multi-trace work correctly.
Additionally you need to use at least cascaded shadow maps to make shadow of hidden object disappear also, if you nedd this. Or mke it cast HiddenShadow if you use CSM but want shadows.
Here is an example:
Follow this question
Once you sign in you will be able to subscribe for any updates here