[c++] How i can detect that all actors in level are loaded?

I want to signup certain actors to other actors’ events, I do this in BeginPlay (), but I’m not sure if all the actors are ready for access . How can I detected that all the actors are loaded to the level and are ready for access?

I’m pretty sure all actors are loaded by the time BeginPlay is fired, but here are some functions you may find helpful:

  • UObjects have the function bool IsValid(YourUObject) which just makes sure the specified object is not nullptr and not pending kill. Use it like this: IsValid(ChairActor) to make sure you can access ChairActor without the game crashing.
  • AActors have the function bool HasActorBegunPlay() so you can use ChairActor->HasActorBegunPlay(); for example, to check if ChairActor has BeginPlay
  • AActors also have bool IsActorInitialized() which can be called similarly but it checks to make sure all components have been initialized.

Hope this helps.

Hi.

You can use the StreamingLevel’s OnLevelLoaded Event. Get a function bound to that event and after the whole level is loaded, you can be sure that all the actors are loaded…

You can also check IsLevelLoaded but then you’ll need to go on a loop and wait until the boolean becomes true.

If you need anything more specific, mention it.

ASIC Level Begin Play is called after all actors Begin Play, so you can call your logic in Level Begin Play…


This would detect all actors in a level and you can loop out to give a value. This is how I would do an actual progress bar or something like that, which would get the total number of assets loaded in vs the number of total actors that is in the map when all the way loaded in. You could bind the events once the number of specific actors = the total of that actor that is supposed to be there when fully loaded.