How would I go about spawning actors/component for one player?

How would I go about spawning actors/components for a single player?

I’m working on creating a chunk based world and the server is responsible for generating the terrain data. However, not all players need all the generated data. Is it possible to only spawn actors/components for the relevant players?

Have you looked at level streaming? It has some limitations, but is fairly close to what you are describing. It got an update in 4.14 to support world origin shifting and now it kind of supports multiplayer. The docs for it say the it only replicates actors to players who need the data, but all actors are on the server.

I had tried that but that requires the level to already exist. I also tried level instances but they only load on the server.

Yeah, I was afraid of that. I have a feeling that if you want to do exactly what you are saying you are going to have to dive in to the source code related to level streaming and then build your system based on that. It sounds like a lot of work.

For what I want to do, level streaming just doesn’t seem to work well for multiplayer, even with the 4.14 fixes. So I am using map levels as chunks to build a larger world and instead of streaming them I am transferring the player between the map servers. Yeah, it has an annoying 1 or 2 second load time, but I get to build worlds of infinite size and performance as long as I have enough map servers. I don’t see any other solution using what is built in to the engine.

After a bit more playing around, it looks like what I want to do is create a subclass of actor that overrides AActor::IsNetRelevantFor. In this function, I can implement a view distance based system. If an actor is outside that view distance, then the server automatically removes it from the client and it no longer replicates to the client until it has entered that view distance again. The view distance used will be the same value used to load and unload chunks.