This is the way I get All Actors in a specific sublevel. Works like a shot, and there’s no overhead because it happens in the construction script.
- Each sublevel is given a name when designing in the editor.
- I use a BP_LevelManager, which is placed in each sublevel.
- Use the function “Get Level Name,” which is on the Level manager, to get the level name.
- Every time I place an actor, I add an interface called Stats Helper, which has the function Return Sublevel Name, which is coded in each actor (you can copy it). In the construction script of each actor, run the code to get the level name each actor is on.
- In the Level manager, compare the name of the sublevel in each valid actor (the one with the interface) with the level manager’s sublevel name, and if they match, add the actors to an array and add to an array called ThisLevelActors.
- All this will be done in the construction script.
- When the game runs, simply access the array for all the valid level actors ONLY IN THAT SUBLEVEL. Works perfectly in my FPS game, which will be out soon.
In the level manager
The Interface call
in each level actor that holds the interface
Get level name in the level manager
Hope this helps you guys.
Thanks for helping me in the past!