How do you handle visibilty in a TOP-DOWN Game?


I have been trying arroung with top-down template a bit and tried to figure out a way to handle visibility of objects, that hide you character when you walk behind them. Imagine you are in a little town with houses which you can enter. Now in order to see your charcter you need to hide everything that is hiding it, like wall, ceilings and maybe even props.

Here is what i have tried so far:

Use a material parameter collection to store position of character and make stuff that occludes him invisible. However, this approach doesn’t look very good, thats why I threw it out of window.

My second approach is, to make everything part of a special blueprint type, that has events you can trigger, which then will hide / show mesh by settings its visibilty. This works, but i have some problems:

How can i determine wether a BP should be triggered to be (in)visible? I tried using rays. problem here is. that if you use Small modular assets for walls, it will only hide pieces that actually occlude player character. I want it to hide whole walls, that might hide not only character, but also important parts of room. effect i would like to achieve is like in game “Sims” (Screenshot: As you can see here, all bottom walls + ceiling of room are hidden. I wonder how it is determined which walls to show and which not, based on camera and character position

What i also forgot:

Is there a way to make a mesh invisible but keep casting same shadows at it did before? Also, cann i somehow change a meshs collision channel at runtime, so it wont interfere with mousclick traces that playercontroller makes when it is not visible?

Hey Brainshack,

You can do a Multi Line Trace by Channel to hide Actors between camera and character, doing something like this:

But if you’re looking to do something similar to what’s shown in that image, you might be better off using a Trigger Volume around your building. When character enters volume, you Hide specific walls you want (looks like bottom and left walls in that image) and ceiling, and leave all other actors visible.

If you are using static lighting, shadows will remain when actors are hidden. Dynamic shadows will not remain. When an Actor is hidden, you it won’t be picked up by your mouse clicks.

Hope that helps!

from four loop you have a toggle hidden array. how did you get that? Im using top down template and i cant hide cubes when i walk behind them. and thoughts?


That’s just a variable of type Actor set as an array. We’re using it to make a list of Actors hit by Line Trace and hiding them all, then unhiding them when Line Trace is done.

This isn’t a perfect setup, though; in effect, this will hide all Actors character runs behind and they will all remain hidden until character isn’t behind anything. That’s probably not what you want, and you’d need to implement a way of unhiding an Actor once Line Trace isn’t hitting it in particular. That’s a bit more complex, but this is this setup is a good way to start.

I have same needs.
Casting a trace as said you can hide meshes. and as described here you can cast shadows. so, solution is:

  • Make a trace from Camera to Pawn
  • Store meshes in an array
  • Toggle visibility
  • This meshes must be setted as “cast hidden shadows” in details pane or by blueprint

How do you get this to work with procedurally placed foliage tool objects though?