[Question] Level Streaming in C++
So we're trying to create a system that allows users to search through every object, including those in levels that aren't being streamed yet. To do this, I'm trying to create a database of objects at startup that can then be searched. My question is, is there a way to stream a level in from C++? This would mean I could stream each level in, get all the objects in it, unstream it, then stream the next etc.
Alternatively, does anyone know of a way I can just access unstreamed levels?
asked Mar 11 '14 at 02:38 AM in C++ Programming
ue4-archive ♦♦ STAFF
In the editor all streaming levels will be loaded, so in theory you could save off some kind of manifest or list of information in to your persistent level indicating where each actor could be found. That said, there is nothing to stop a sublevel from being opened and edited on its own, so there is no guarantee that it would remain accurate.
If you want to manually force each level to be loaded you could use the UGameplayStatics::LoadStreamLevel function, just as it would be used from blueprints to load each level, pull the information out of it you want and then call the UnloadStreamLevel function.
Writing Out Binary Files
You should look up Archive.h and ArchiveBase.h
you can write out to file a list of all objects and their values for all levels
and then each level can access this database from hard disk, and also update its contents
it is written out to a binary file that goes into a file of your choosing the user's harddrive
sort of like a local user profile :)
UE4 already supports serialization of most data types and objects using the << operator.
I've used this system as the foundation for the saving and loading of my levels in my in-game editor where the user creates the level during runtime.
Archive and ArchiveBase classes are your friends!!
I recommend using the FBufferArchive, it is a binary array (TArray) as well as being an Archive (multiple inheritance)
I use FMemoryReader to get contents back out of the archive saved to disk
You can compress your binary files using ZLIB and the compression system that comes with Archive and ArchiveBase
If you need more exact details / code samples let me know
My main computer is down right now (needs new motherboard) so its not that easy for me to get code samples.
Follow this question
Once you sign in you will be able to subscribe for any updates here