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


I have been trying arroung with the top-down template a bit and tried to figure out a way to handle the 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 the position of the character and make stuff that occludes him invisible. However, this approach doesn’t look very good, thats why I threw it out of the 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 the 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. The problem here is. that if you use Small modular assets for walls, it will only hide the pieces that actually occlude the player character. I want it to hide whole walls, that might hide not only the character, but also important parts of the room. The effect i would like to achieve is like in the game “The Sims” (Screenshot: As you can see here, all the bottom walls + the ceiling of the 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 the same shadows at it did before? Also, cann i somehow change a meshs collision channel at runtime, so it wont interfere with the mousclick traces that the playercontroller makes when it is not visible?

Hey Brainshack,

You can do a Multi Line Trace by Channel to hide Actors between the camera and the 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 the character enters the volume, you Hide the 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!

Ben Halliday

from the four loop you have a toggle hidden array. how did you get that? Im using the top down template and i cant hide the 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 the Line Trace and hiding them all, then unhiding them when the Line Trace is done.

This isn’t a perfect setup, though; in effect, this will hide all Actors the character runs behind and they will all remain hidden until the 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 the 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 the same needs.
Casting a trace as Ben Halliday said you can hide meshes. and as described here you can cast the shadows. so, the solution is:

  • Make a trace from Camera to Pawn
  • Store the meshes in an array
  • Toggle the 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?