Is it possible to do level streaming in a multiplayer game? Also I am thinking of making a hunting game which I would like a decent size map. Is it possible to make a good size map in UE?
Hey Netfox,
Level streaming does function in multiplayer games. However, when any player steps into a level streaming volume, connected level will load for every player, even though other players are not inside that volume. Logic for streaming volumes is hardcoded to replicate streaming state changes to all clients, so level streaming in a multiplayer game may not be useful without changing source code.
You can, however, achieve a similar effect with some creative use of Blueprints and Trigger Volumes.
This way streaming level will only be streamed on client when local character steps into Trigger Volume.
Hope that helps get you started!
Thanks for pointing this out. However can I ask you how you would stream players for example. Imagine you get into a new area and there are a few players in there at moment. They shouldn’t be visible if you are outside that area so that kind of dynamic content should be streamed too. In this case pawn cannot be assigned to a specific level or should it be done that way each time a player enters or leaves an area ?
same question applies to anything that could potentially be relocated to a different area during game (runtime).
You wouldn’t want to stream characters. Streaming actually loads and unloads assets from game, and you wouldn’t want to remove a player’s character from game so that another player wouldn’t see it.
What you’re looking for is replication based on distance from a player, I think. Check out this video tutorial series from one of our developers:
This includes information on how to set whether an actor or event is replicated for a client based on its distance from player.
If you have more questions about how to set that up, please open a new post with your questions as they don’t really fall under topic of level streaming. But if you do, please link to it here so that others with same train of thought as yours can follow along. Thanks!
Thanks for your reply. I have already watched those videos and I’m not so sure they apply in this case. I actually really did mean loading and unloading assets. When you make a level streamable all actors (thus assets) attached to it are being loaded and unloaded with it. Now I’m talking about a case where some of those assets would be allowed to change level during runtime.
Lets imagine an MMO game where players can drive vehicles. If a vehicle is set to be streamed with a specific level it would mean when a player drives it to another level another player would not see it in that very level as it would only get loaded into its (client) memory while he’s walking on vehicle’s initial level.
Replication (if I understand it correctly) is meant to synchronize data. Meaning if a chest is not visible to a player due to distance its state and configuration information (like is it open or not etc) can be directed to a player from within a certain range. My point is whatever player’s distance chest will still be loaded into its memory. Maybe it will get loaded when it becomes replicated but it wouldn’t (as I understand) get unloaded once player leaves predefined range.
In an MMO-like game with a huge map and hundreds of thousands of objects (actors, assets, whatever) you cannot imagine having all those assets continuously in a client’s memory. Distance culling and distance-based replication are in my opinion a different matter. Here I think I’m really talking about content streaming for loading and unloading on demand.
I hope you understand what I’m trying to say. Maybe replication does participate in some memory cleaning. Maybe garbage collector you use does load and unload some things at some specific times. But it sounds strange to me.
Sorry for insisting and actually still replying here. I will make a dedicated question if you confirm that this doesn’t apply to this one.
Thanks again.
For a much larger world, you would probably need to use something like World Browser, though there are some known limitations in regards to multiplayer. MMO-like games require a great deal more custom setup than a simpler level using level streaming as described above. I believe you’re correct about replication configuration not being solution to your problem; I misunderstood what you were trying to achieve.
I would recommend checking out some of information in this forum post, starting with Sean’s and ddvlost’s responses:
I’ll check in with a few developers and see if I can find someone who can give you some more insight regarding larger-scale multiplayer.
Thanks. I’ll keep reading on there when I have time. Note that I’m already aware of how to use World Composition and its critical multiplayer limitation:
“Multiplayer also adds a restriction that world origin rebasing should be disabled”
If I read correctly we’ll be limited to a +/- 5km radius around world origin.
I hope this will change in future.
Thanks for your replies. And to point out that link that will be useful if they keep it up to date with changes as they come.
Hi,
Dedicated server does not support this kind of things. Spawned players will exist on all clients, regardless of distance and will be removed only when player is disconnected from a server. same rules apply for all other actors, they will stay in memory while owning level is still loaded.
Now I’m talking about a case where
some of those assets would be allowed
to change level during runtime.
I think actors should not change levels. With your vehicle example, streaming level should not own vehicle. Streaming levels should just own spawn points with information what kind of actor should be spawned from here, and when actor is spawned it should be in persistent level.
Unreal dedicated server does not work as MMO server, it can be used as an dungeon/instance server. Our licensees usually write their own MMO server solutions.
Ok thanks for precisions.
Our licensees usually write their own MMO server solutions. Would be nice to get more info about this theme. How to build a own server solution. Where to get info about this? Thanks!
Sorry for grave digging but this has never been resolved. Are there any resources or code plugins that can help stream levels in and out locally? Is Epic planning on supporting this in upcoming versions?
I’d love to have world composition / level streaming supported with dedicated servers. Please make it a thing!
Unfortunately that doesn’t entirely work. It will make it visible on client for only client, but it won’t replicate location of client player. For example, if you have a block that is in its own level and you stream it in they way you suggested, which I tried, if you make client player jump on it, it won’t have correct location on server. So it’ll be flickering back and forth or like in my case it will fall through map since it’s not seeing it entirely. It’s weird, it shows up but collision doesn’t work. Is there a new work around to this, or is only workaround c++?
Wait, actually my method was a little different. I’ll double check tomorrow and see if it works. I’ll update tomorrow.
I’m interested in outcome of this test!!
Yep, just tried it again and while it visually loads level, collision info doesn’t seem to turn on. This doesn’t work.
For those interested way I tried it first time was that I streamed level at begin play in gamestate, then I used trigger volume to “get streaming level” and “Set should be visible” to true. I set it to untrue on end overlap. I did this because I didn’t want any fps drop on loading (still looking into async) But then I tried version above where I actually used volume to load level and unload it, but it’s same result. It shows up but my client player falls through map. I even tried running stream through a server event and a multicast event, but it didn’t work. I know it’s because client doesn’t have authority. I just tried a test where I called game state and ran it through there on server, no luck.
I’m probably going to still use this though (modified and without the “is local controller”, since it’s better than nothing, and better than all parts of map showing. For example, if my server player is in castle, and client is in dungeon, I’ll at least still do culling and max draw distance stuff. That way Forest, lower arena, and village are all still unloaded.
This was my solution.
On overlap, it add’s player to an array and set’s streamed level to visible, then it sets tick to enabled. I have tick updated every .2 seconds.
On end overlap, it removes player from array.
Tick is checking to see if players = 0, and when it does it sets streamed level to not be visible and it disables tick again. Works well so far.