The problem i am having is :
If i am on a “Game Preview Server”, when i press RMB on a random map location, my Pawn moves to that location and spawns ClickLocation Actor as a indication of clicked location.
But if i am on the “Game Preview Client1” , all that happens
is just Showing this “Click Location” Actor, and not moving the pawn.
Sorry for bad resolution on my last Picture, the text on left is : “Focused game instance” , and text on right is: “The same does not apply to client(even when focused)”
How can i fix this problem? If there are more informations needed, i will send picture, or try to answer.
GetAllActorsOfClass does not guarantee that you are getting the same order of Actors on different devices so index 0 and index 1 could easily be the “same” replicated Actor.
Also here is some multiplayer guidelines you should follow
Always set a replicated variable server-side. Setting a replicated variable client-side makes that variable go out-of-sync which you rarely want to happen for very long.
No need to use SwitchHasAuthority on input events (Right Mouse Button) since it just adds unnecessary complexity. It is perfectly okay for a Server to call a RunOnServer RPC it will just make the call as a regular function.
The server should be the only one Spawning and Moving things and the Clients just send their input to the Server. If a Client Spawns or moves something it will never replicate since replication can only happen from the server to the clients. The exception is when allowing the client to move for example its character to prevent input-lag. Then the client is moving its own character with direct input while also letting the server know what it did so it can follow up and confirm the move.
AI also mostly only run on the server if it has any impact on the overall game.
If you use GameModeBase you need to use GameStateBase and if you use GameMode you need to use GameState.
I was referring to when you set “Controlled Pawn Ref” in the “Remote” flow. Remote is client-side so when you set the variable here even though it is replicated the server will not know about it.