How do I hide components in front of my character in a top-down view game?

Hey ,

Level Streaming isn’t a good solution for this, as it actually loads and unloads assets inside level, and excessive use of this will cause some hitching in your game, and will likely have a higher processing cost than is necessary. Using trigger volumes could work, but as you mentioned it’s not a very modular approach to your design and would cost you in time.

Using a line trace or capsule trace is best way to handle this. With some creative setup, these line traces can be used even in situation you described. Here’s an image of how I set this up in my top-down project:

12325-hideprimitivecomponentslinetracebychannel.png

What I have here is a Multi Line Trace by Channel between a sphere component I put on my character’s head and character’s camera. It does a quick check to see if it’s hitting anything, and assigns everything it’s hitting to a temporary array. I do a ForEachLoop to check each Actor hit, use Break Hit Result to get every Component hit, and set it Hidden in game. ToggleHiddenArray is just to keep track of what I’ve set hidden, so when there’s nothing being hit it sets hidden to false.

In this scenario, we’re taking Hit Component instead of Actor, so in a case where you have a Blueprint with multiple components it will only hide components crossing line trace and not entire Actor.

This isn’t a perfect setup. For example, you’ll likely need to add checks so that it un-hides components when they’re not in line trace rather than when nothing is in line trace; as it is, components won’t be un-hidden until character moves to a place where nothing is in between character and camera. Still, this is a good starting place.

You may also need to play with Visibility collision settings for your Actors, Components, etc to make this work.

Hope this helps! Let me know if you run into questions with it.