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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

World Composition: Event when a level is loaded (C++)


I'm trying to build some kind of data driven game (with NPC's and such). I'd like to spawn NPC's only when their level is loaded. I'm using world composition (needs to be some kind of open world game). But i'm not seeing any event noticing me that "hey, this level has loaded now!" and "this level has unloaded!" Does this kind of thing exists? Or that implies that i'm doing the loading stuff myself? (I mean, without adding code to every single level to trigger that..) Thanks !


Product Version: UE 4.22
more ▼

asked May 01 '19 at 10:03 AM in C++ Programming

avatar image

41 2 5

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

1 answer: sort voted first

Hey, you could simply hook on your GameMode code "BeginPlay" it's called when the world is initialized

else if it's with level streaming, you can use these events ( can be hooked in beginPlay Aswell i guess ) :

     ULevelStreaming* level = UGameplayStatics::GetStreamingLevel(GetWorld(), *MapName);
     level->OnLevelLoaded // with AddDynamic
more ▼

answered May 01 '19 at 12:53 PM

avatar image

1.5k 14 18 32

avatar image Flemmard May 01 '19 at 01:01 PM

Yeah but this only procs when the whole level is loaded, not every sublevel?

avatar image Firefly74 May 01 '19 at 02:57 PM

the begin play will be triggered at the beginning of the game ( so when all persistent levels are loaded )

for the second part, it's related to each sublevels, you would need a list of sublevels name to iterate on that and register event for all sublevels

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

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

Answers to this question