Good evening, I would like to know how I can spawn an actor on all clients in the network, including the server. Example: I called this event on Client 1, and only client 1 spawned the actor. The server can see the spawned actor, but on the server was not spawned. If I execute the event on the server, only the server will spawn the actor and the client will be able to see it too but the actor will not be spawned on client.
I’ve been trying for days to figure out how this works, and where my error is in the code, but so far I haven’t been able to understand it. Thank you very much if anyone can help.
I’m not really sure MC_Spawn is needed. Just the call on the server should do the trick - ROS_Spawn to spawn the actor. Just make sure the actors you spawn are replicated and that you call the server function from a BP that is owned by the client. (i.e. from the character you control)
Collision Handling Override :: Try to adjust Location, But always Spawn
Get Actor Location as the Spawn Transform Location is going to spawn the actor inside the Capsule Component. Actor Location of the character class is Always the center (X,Y,Z) of the capsule component.
Default will spawn it inside the characters pelvis area, then depenetration is going to push the character class out of its collision.
It would be something like if the client that called the event executed this call to “spawn” the actor in the other clients of the network too, like remote command, but I don’t know how to do it
If I call the event from other clients, the actor is spawned correctly too, but with the same exception as the server, it is spawned only on the client that called it and the other clients on the network can see this spawned actor, but on the other clients the actor is not spawned
I want exactly this effect (spawn for all clients) after the initial call. Example: Client 1 call to spawn, the actor will be spawned in all clients in network
CLient 1 calls to Spawn…
The same actor need to be spawned in
Client 1
Client 2
Client 3
Server
Thanks for everyone’s help, you guys are the best!
This is the key word “GetAllActorsOfClass(Player)->CallEvent(SpawnCube)” to solve my problem, thank you very much, the solution is exactly this, see the result, now all actors are spawned in all client, this is exactly what I need, thank you very much.
If you want “all connected clients” to spawn a cube, then the best approach is go through controller to Game Mode and have the GM loop the Game State Player Array.
For Each (Player Array) : Get Pawn → Spawn Actor of Class (set owner && Instigator)
This will have the GM spawn a replicated cube for each connected client.
Note: The GM only exists on the Server. Clients do not get a copy of the class, So you have to RPC to server and have the Servers proxy call the GM.
Awesome, thank you very much, I learned something more by looking at your code.
It’s amazing how this clears up many doubts I had about how to access all the players in the room and run events on the network.
We can access and change any data through GM
It worked perfectly. I see that you used the “Get Pawn” reference in the loop, I didn’t do it that way, I threw the direct connection in the loop (going through all the items of the class), maybe that’s why I had some errors in the past using loop, your code seems to be better, because it filters the reference only for “Pawn”, this is a way to customize loop, filtering only what is interesting in the reference, very good