in my project I want to spawn many actors (100.000). Without instancing it is not possible to do it right, because there are too much triangles and it loads very long, while creating the actors.
I see only one method to resolve it. The instancing.
The Problem is that I use replication in my project, but replication with instancing actor components doesnt seem to work. The Client cant see the instances. Without replication every game instance spawns the mesh instances on different locations. (I spawn the mesh instances on random locations in a range).
Can anyone help me with spawning a lot of actors with replication and collision?
Hi, if you want to use instancing, then AFAIK you would need to manually sync them. So if you want to place those instances randomly, then one option might be to use a seed and only send that to the client and place those instances locally on client and server. Otherwise you could send all the transforms of all the instances from the server to the client and place instances with those exact transforms on the client (if you want to also make changes to them during the game, then make sure to add them in the same order on the client as on the server). But keep in mind there that you can only call the same RPC twice per frame and there is a limit on the amount of data you can send through an RPC at once (don’t know whether that is something from the RPC or just the bandwidth limit from the config files). And repnotify might also give you problems when trying to replicate an array of 100.000 transforms…
So basically as I understand it, if you set a seed then you will get the same “random” values every time. So you then just need to send the seed you want to use from the server to the clients and then use that to generate the random transforms.
I tried this method and it works, but because of the seed the spawns are every time the same. Therefore I used the function “Seed Random Stream”. So everytime the function is used, it updates the random spawns. But then there is the same problem again, the spawns are different on the server and client. I call this function on begin play, so the Server and the Client execute it, I think thats the problem.
I think the real problem is the following…
I want that the server generates random floats, when the game beginns. The other clients should access these random floats and do not generate own random values. Also clients, who joins the game later sould access the variable, which the server sets at the beginning.
This prints the same values on server and client. It’s not totally random since you have a limited number of integers and therefore you have about two billion combinations to choose from, but for the player it should feel like random.