Replicated actors spawning twice with level streaming

I have a randomly generated map spawned at runtime using streaming levels, and have an issue where any replicated actors placed inside those levels will spawn twice for the clients.

I am spawning the levels on each client, so it makes sense. But it’s an issue because I only want the replicated actors to spawn once - on the server, and then be replicated to the client. Otherwise I run into issues where a client picks something up and it doesn’t disappear, because there was an actor on both the server and the client.

How can I create randomly generated maps on each client using streaming levels, while also having the ability to place replicated actors inside those streaming levels without them doubling up and being created on both the server and the client?

Thanks. Jackson.

Lets see the spawning code and replication settings.

  1. Set a seed integer on the server
  2. Spawn a grid of streaming levels on each client using the RepNotify function when the seed is changed

Each client generates the same map from the streaming levels, but any replicated blueprints within those streaming levels are also spawned on each client.

Looking for a way to spawn streaming levels from the server side and have them replicated to the clients.

Setting the seed of my random level generator on the server

Picture of my persistent map with the sub-levels I will be creating instances of at begin play shown in the levels tab in the top right

RepNotify function which is fired on each client whenever the seed is changed on the server, causing the same map of streaming levels to be generated on each client

Zoomed out pic of the level generation code

The node I’m using to create instances of the streaming levels.

How on earth can I get these streaming levels to replicate to the clients??? Because at the moment I need to exclude all replicated blueprints from my sub-levels, and then spawn them dynamically from blueprints on the server side only once the streaming levels have been loaded.

Regenerate Random Levels … Spawn Instances section Add a Switch has Authority and execute off the AUTH pin.

This will make it so that ONLY the server Spawns the level based BP instances. Those Instances need to all have “Replicates” ticked in the class settings.

Actually I think I jumped the gun on this.

Where are the BP instances initialized?

The BP_GridRandomLevelGenerator is in the persistent level. The sub-levels are up in the level tab shown in the second screenshot. I want to dynamically spawn instances of those sub-levels at runtime for multiplayer - i.e. have them replicated to each client.

My issue is if I spawn those instances on the server only, then the clients don’t see anything. But if I spawn the instances on each client as well, then any replicated actors inside those sub-levels begin to behave strangely on the clients (i.e. multicast events not firing, pickups not disappearing when overlapped, etc).

This is what I started to think you where doing.

But to be clear… you have sub level grids (Actors) that spawn other actors?!

I figured out a workaround. I added an actor component to each replicated actor I would be placing in sublevels, which at begin play would send it’s class and transform to the level generator and then destroy itself.

The result:

  1. Set the seed on the server as a replicated integer
  2. Use that seed to generate the same map on EACH CLIENT, but only the nonreplicated actors
  3. After the map is generated on the server, go through the list of classes and transforms collected from the actor components mentioned above and spawn them all on the SERVER ONLY

Note: The actor component cannot be in the replicated actors default settings - it must be manually added after placing that actor in a sublevel otherwise the newly spawned actor at the end of the level gen will also have the component