i have a ‘little’ problem where i don’t know how to proceed.
I’m working on a game which wholly relies on runtime procedural generation.
(Starting the game will calculate the game world/levels, code inside GameMode works fine)
What i can’t figure out, is how to add streaming levels to my world.
Level generation is not the problem, but i would like them to be streamed, since i have multiple floors. The floors themselves can be quite big, so my ultimate goal would be to divide one floor into multiple parts too, but floor by floor is more important.
How do i convert a UWORLD to a ULEVEL? Direct cast doesn’t work (no wonder) and i didn’t find any functions to save a world to disk (functions which are not based on editor code).
Will levels automatically be loaded/shown if i set the streaming volumes correctly or do i need additional code for that? (added with uworld->AddLevel)
Will levels added to the World in StartPlay of the GameMode be ok or do i have to pre-generate the world with the levels, then save and reload?
An UWorld is not an ULevel, so you can not just save/load or transform between them. If you use streaming volumes and out-of-the-box level streaming all will be handled automatically.
While I guess you are not seeking for adding level in editor rather than in runtime. For a more procedural approach of levels you can use the BP node
Load Level Instance, you can use it to load a level and spawn in your current world. Thus it does not get replicated automatically, neither do BSPs work in them (every BSP will stay at they relative position).
The bad news is that the method is not available to C++ because it’s exposed as the
MinimalApi but again, you can just check what it does. In my case I use my own one that implements replication.
Regarding when to generate the level I generate the data in the server (GameMode could be a good place, depends on your game though). Once you know what to generate you just send that source data to each client and sync the world generation. Same applies for a SP game where you just load/save the source data used to generate your level.
Thx Moss for the answer.
I see what you referring to. But Load Level Instance isn’t what i’m looking for.
What i need is:
Empty UWorld to add streaming levels to(ok)
Empty Map/Level (how?)
Create content in empty map (should be no problem)
Save Map (needed, since calculation take some time)
Load Map parts on demand aka streaming
My content generation builds on instanced static meshes and quite a bit dynamic lighting. While the ISM’s can easily be occluded, the light sources steal quite a bit fps. Thats why i want to try it with streamed levels. 100 lights or 500 lights make quite a difference even when not shown (Particle effects etc). I probably can optimize them more but my thought was: whats not loaded cant be calculated → doesn’t eat fps.
You can just open a new map from code in the editor but you wont be able to load/save a map in runtime without editor support.