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.

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.

Thanks for the reply. The only thing I can’t figure it is how I can hide the landscape too. I wish there was something painfully simple like being able to shape and size a UMG widget to cover the screen space that isn’t visible in just black or something.

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: