Download

Streaming levels with an offset.

Hey epic, I really like the streaming feature but I was wondering if it’s possible to stream them in at a different position than they are built? The reason I ask is because I want a randomly generated dungeon at run-time. I want to be able create different shaped rooms and then while the player is playing, randomly spawn one.

What I DONT want is to use construct script and randomly generate a dungeon like a maze in unreal editor. This is an awesome feature, but I want to spawn pre-created/lightmapped scenes at a location that I specify.

Please let me know if you need more information.

Cheers,
Oz

Hi Osman,

It sounds like you may want to work with the World Browser. However, the World Browser is still very much a Work-In-Progress, it currently has no documentation, and it is disabled by default. You can enable the World Browser under Preferences > Experimental, but there is limited support for the tool at this time. A little bit of information can be found by searching on the AnswerHub, however it is mostly archived posts from our past beta test, and thus may be out of date. Some important information is copied below. Happy developing!

Wow! That’s a great feature! Opens a lot of doors and I’m definately going to really dig into it. For now I quickly tested it out and it seems its very nice for huge huge worlds but not really quite for randomly generated worlds. Or perhaps I missed a feature where I could set a tile position randomly during run-time?

Thanks for pointing it out btw!

It is possible to do it with blueprints. You will need to add all your levels as a streaming levels to your main map in the “Levels” tool.
Then in the persistent level blueprint you can do something like this.

Make sure that all streaming levels has “Blueprint” streaming method.
Unfortunately there is one limitation right now, level transform will work only when you start your game as “Standalone game” in Play menu, so when you play in the editor viewport it will not work.
And I’m sure this kind of procedural world will not work with static lighting well. You will need a fully dynamic lighting.

Hey ddvlost, thanks for your help! However, I can’t seem to find the ‘Level Transform’ variable. How did you access it?

Edit:
Also, if this won’t work with static lighting, are there perhaps any plans to make it work? I’d hate to lose quality that lightmaps give me :slight_smile:

It should appear in a menu when you drag a return value pin from “Get Streaming Level” node.

Lightmaps will work, but for example indirect lighting cache which is precomputed by Lightmass will not work correctly, because it assumes that geometry is static and will not be changed after lighting is built.

Ok, very creepy, now I could find it but before it was not showing haha.Thanks!

So I played around with it, and it seems to work like I expect it besides a couple of problems. You mentioned some of the issues with it of course, but I noticed that another limitation of this is that I can’t have the same level laoded twice in 2 different locations. So this makes it not usable for randomly generated levels :(. Thank you for showing me this feature however, it should come in handy anyways!

Do you happen to know if theres anything in the works/plans for what I want? Basically being able to spawn a single ulevel in different locations?

Creating streaming level instances from BPs, will be a nice feature to add. It’s already possible to do it in C++, Fortnite uses something similar to generate procedural worlds.
I will add this request to our backlog, thank you for suggestion!

Awesome! Thanks a lot. Is there any documentation on how to do it in c++. Even a couple of keywords would help me get started ( im not decied on blueprint only, if I have to use C++ a bit, that’s fine!)

Here is code snippet that should work


void UWorld::AddLevelInstance(FString UniqueInstanceName, FString PackageNameToLoad, const FTransform& LevelTransform)
{
	ULevelStreamingKismet* StreamingLevel = Cast<ULevelStreamingKismet*>(StaticConstructObject(ULevelStreamingKismet::StaticClass(), this, NAME_None, RF_NoFlags, NULL));
	
	StreamingLevel->PackageName = FName(*UniqueInstanceName);
	StreamingLevel->PackageNameToLoad = FName(*PackageNameToLoad);
	StreamingLevel->bShouldBeLoaded = true;
	StreamingLevel->bShouldBeVisible = true;
	StreamingLevel->LevelTransform = LevelTransform;

	// add new instance to streaming level list
	StreamingLevels.Add(StreamingLevel);
}

PackageNameToLoad is a name of map package on the disk that you want to load and UniqueInstanceName is a name of the level instance, which should be unique. After a new streaming level instance was added you can access it from BP using “Get Streaming Level” node by providing UniqueInstanceName to it.

Thanks ddvlost, that works well for me, although I had to make sure the UniqueInstanceName passed in is a valid package path (i.e., /Game/Maps/MyLevel, not just MyLevel), otherwise the engine hangs without any diagnostics. There is also a typo in the code:


Cast<ULevelStreamingKismet*>

should be


Cast<ULevelStreamingKismet>

Right, that has to be long package name, just make sure that /Game/Maps/MyLevel is unique.

Thanks for the clarification on that. Now I have a new problem:

Brushes don’t respect the level transform. I can live with this and build geometry out of static meshes; however the lightmass importance volumes appear to be based on brushes as well and so the light probe samples don’t transform with the level transform; this is a much more serious issue. Can you think of a workaround?

As I understood you need a level transform applied while in the Editor to build a static lighting? In this case you should not use a level transform in BP as it intended for dynamic cases. Editor has a functionality to transform levels, in the “Levels” tool context menu enable View->Show Editor Offset, you should see a new column with a level transform options. When you do apply a transform there, brushes will be correctly transformed as well, so you can build a lighting.

I will look at why brushes are not transformed when you use in game level transform (in Blueprints)

I’m using the level transform to instance levels at run-time procedurally. The final position of the level won’t be known at editor-time, so I can’t use the editor offset. I’m using levels instead of instantiating blueprints as I want to use static lighting.

Hey Alex/ddvlost,

I was wondering if you had any luck with the lightmass information and bsp not moving with the level transform? Very handy thread by the way, thanks!

David

Hey guys, I was going to ask the same thing :slight_smile:

How far along are we to be able to stream in our levels dynamically at any spot we wish?

I noticed that in 4.2 they added the follwing:
**
New: Added CreateInstance function to ULevelStreaming and exposed it to Blueprints. This change allows to create a copy of existing level streaming object with a new unique name, so user will be able to stream-in/out multiple instances of a particular map package.**

Is this relevant for the issue at hand? If so, is there an example on how to use it?

Thanks in advance and great work!

Has there been any progress into looking at why brushes/volumes do not translate with the level transform of instanced streaming levels? I am currently using instanced streaming levels to produce a infinite scroller. This issue is a show stopper since I am targeting mobile and need to use static lighting only. The indirect lighting cache doesn’t move to where the level is streamed in, leaving all movable components in the dark.

Thanks!

@Kostrowski - for now try to add LightMass volume in your persistant and Directional Light. As far I know Epic is working on something like DLE from UE3 on Mobile, so we will be able to lit dynamics objects as we like.

Also interested in being able to offset levels with static lighting intact. Currently working on doing things with blueprints which would be quiet a bit more flexible but prevents using static lighting. Building “levels” in the component editor is not as nice as using the full editor either. If possible I would rather sacrifice this extra flexibility to be able to use static lighting and make content creation a bit easier.

Is it possible to offset the static indirect lighting even if it is limited to offsetting the location?

Anything other than geometry, volumes and static lighting that will not get translated with the level?

Going to grab the engine source this weekend and dig a bit. Any pointers on where to look, what to consider etc are of course welcome.