Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

[Closed] Streaming levels without calling BeginPlay

We'd like to have granular power over when packages are loaded versus when they are "begun". Is there a way to do this? It looks like even when you send false to bMakeVisibleAfterLoad in UGameplayStatics::LoadStreamLevel, BeginPlay is called on the level.

Seeing as BeginPlay is the final step called on an actor as far as I understand the content pipeline, that seems very limiting. We just want all the assets ready, invisible and inactive, floating in RAM until we hit the switch. Is there a way to accomplish this?

Alternatively, is there an event we should move our BeginPlay logic to instead, that only fires when we set it to be visible? That's not an ideal solution since that would be a pretty big migration, but it seems pertinent to ask.

In a nutshell, we want to separate the idea of "loading" from "activating", if that makes sense.

Product Version: Not Selected
more ▼

asked Sep 22 '16 at 06:19 PM in C++ Programming

avatar image

Answers.Archive STAFF
1.9k 208 316 688

avatar image Answers.Archive STAFF Sep 22 '16 at 06:19 PM

It totally makes sense that you could have levels you load and keep inactive. ...And the good news is that you definitely CAN do that. But the bad news is that you'll have to make some local changes to the engine code and then integrate your changes any time you take a new version of the UE4 engine. We have massive changes throughout the UE4 engine, so that's just part of life for us.

Anyways, you could make some code changes where BeginPlay() is only called when you set the level to isVisible = true, OR you could also go with your event idea and broadcast the even when you set the level to active/visible.

The code for all this shouldn't be too tough to do.

Without writing the code for you and posting it here, I'll point you in the right direction. (Mainly because I have changed the hell out of World.cpp in our codebase so any code I copy from there isn't going to match your for the most part and will only confuse you.) :P

Start by checking out:

 void UWorld::UpdateLevelStreamingInner(ULevelStreaming* StreamingLevel)

Then check out UWorld::AddToWorld() method. You definitely going to need to change AddToWorld's behavior to not just set the level to visible and broadcast that the level is changed / visible. You'll need you add your own code that set the added to world level to dormant instead until you say it's time to set it visible and then call this following code at the end of AddToWorld():

         // Notify the texture streaming system now that everything is set up.
         IStreamingManager::Get().AddLevel( Level );
         Level->bIsVisible = true;
         // send a callback that a level was added to the world
         FWorldDelegates::LevelAddedToWorld.Broadcast(Level, this);
         ULevelStreaming::BroadcastLevelVisibleStatus(this, Level->GetOutermost()->GetFName(), true);

Hope this gets you on the right path!


(comments are locked)
10|2000 characters needed characters left
Viewable by all users

The question has been closed Sep 22 '16 at 06:20 PM by AndrewHurley for the following reason:

The question is answered, right answer was accepted

1 answer: sort voted first


BeginPlay on sub-level actors should be called only after sub-level became visible. UGameplayStatics::LoadStreamLevel with bMakeVisibleAfterLoad=fasle should just load level package into memory without making it visible. If you see that BeginPlay called on hidden level that a bug. Do you see this issue in PIE or in standalone game?

more ▼

answered Sep 22 '16 at 06:19 PM

avatar image

Answers.Archive STAFF
1.9k 208 316 688

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question