Dynamic level streaming with multiplayer support

Yes, though I am doing it through c++. It looks like this:

		FString PackageNameOverride = TEXT("StreamedLevelInstance_" + LevelCount++);
		LevelStreamer = ULevelStreamingDynamic::LoadLevelInstanceBySoftObjectPtr(this, LevelPiecePtr, TargetTransform, Success, *PackageNameOverride);

Ok. So in BP there is this…

Do you set “LevelPiecePtr” to something?

Do you set “TargetTransform” to something?

Is “Success” a variable you check after you make the call?

Do you do anything with “LevelStreamer” after you make this call?

LevelPiecePtr in my code corresponds to the Level input on that node: it’s a ptr to the UWorld that you want to load.

TargetTransform is the value I’m passing to the Location and Rotation field, as a Transform has both. It’s the location in the current level I want my level instance to be loaded at.

Success I don’t use, but if you want to check that the level loaded properly, it will set Success to true in that case (Out Success on your bp node)

Optional Level Name Override is what you set to enable replication. Each needs to be unique, but each Instance on the client and server needs the same one. I am loading the same instances in the same order on server and client and using “LevelInstance_1, LevelInstance_2, . . .” as the names.

I do stuff with the LevelStreamer (what is returned by your BP node) but that’s largely down to the specifics of my implementation, you may not need to. The LevelStreamer has callbacks that you can use to know when the level has been loaded into memory and when it has actually spawned in the level, which I have functionality attached to but you might not need it.

Also, for what its worth, there is a version of that function and BP node that takes the level name instead of the pointer, if you prefer that. I prefer the pointer.

1 Like

Adding my 2c from experience in 5.2

I couldn’t seem to get it working with Create Instance node:
image

I had to switch to LoadLevelInstance (by Name):

I learned that Optional Level Name Override is essential, AND it doesn’t seem to take some characters. I’m not sure if it was a “=” or a " " (space) which broke it, but once I edited my generateUniqueStreamingLevelName function to return a unique name for every single level instance that was guaranteed to be the same on both server and client (AND WITHOUT those aforementioned characters) I was able to get it working.

Inside my generateUniqueStreamingLevelName function (if it is relevant to anybody curious):

3 Likes

binary or hash related perhaps?

Oh. My. Goodness.

Thank you for this! This information saved me and should be marked as the solution! Props to you @TG_Daniel !

1 Like

@jacksonnexhip Where are you pulling LV Streaming Level Info from?

I can’t seem to find a reference to this anywhere.

What is the blueprint pendant to this function call? I would like to try it using Blueprints instead of using C++