[Blueprints Q] Best way to reference all static meshes in a level?

In a blueprint you would use get all components of type, but I’m not sure if it is possible for the level blueprint.

I’m trying to hide / show all Static Meshes in a particular level for multiple levels. My logic decides which one(s) should currently be visible ingame.

Previously in UE3 you could set an entire level to be visible / invisible. However you can’t in UE4 so I’m trying to add Static Meshes to arrays specific to their levels. I can’t find a way of finding out which level a particular Static Mesh is in though. If I use the ‘Get All Actors Of Class’ node it will get all Actors in all levels, not just the current level.

I’d prefer not to have to add a reference to every individual mesh in each level graph and maintain that list as meshes are deleted & added.

Any ideas on how to achieve t his?

That’s what I’ve done already, but as you say, it doesn’t include any level information :frowning:

If you spawn your enemies in code you can easily add a variable to each instance that tells what level it is part of, that way you can get all actors of class and compare this variable to whatever level you’re interested in.

It’s not pretty but it’d work. Making the same variable public would work too if you place your enemies manually.

If you have code that uses an ‘open level’ command you can store this variable as well and use it when the actors are spawned.

I’m not aware of any other solution but there might be, it’d be easier than maintaining a list of actor references at least! :slight_smile:

Unfortunately I’m using Blueprints only and dealing with Static Meshes, not enemies.

I’d like to know if it’s intention or oversight that stops devs from accessing level information relating to pawns within BPs.

I don’t know if you still need an answer for this, but you can use World composition to split all your actors,meshs and everything up by "level, then simply make each level of objects visible or hidden (or unloaded/loaded). Just pick a level, go to world settings and click enable world composition, and it will add the other levels to your scene. then using blueprints you can choose when to load or unload huge sections at a time.

In my level I have two versions of the same map and by pressing a button i can unload and load entire levels of different meshes, while my character stays in the same place.

Reply to this if you want me to go into more detail, if you still need a solution.