Replicate function from Game State
I created two variables in my custom Game State (MyGameState) called MasterNumber and PlayerNumber, they are defaulted to -1. I have a simple UMG blueprint with 2 buttons where a player can click. If a player clicks on the button that has "Master" as text initially, the OnClickEvent calls SetMaster in MyGameState that checks if MasterNumber is -1. If it is, it changes the value of MasterNumber to MyPlayerState->PlayerNumber (note that this is different from MyGameState->PlayerNumber). Once this value changes, another function on the same UMG blueprint that is bound to the text that was initially "Master" should now return a different text. This function checks if MyGameState->MasterNumber is -1, if it is it returns "Master" if not, it returns MyPlayerState->PlayerName for the player with PlayerNumber == MyGameState->MasterNumber.
What happens is, I'm setting MyGameState->SetMaster to be replicated "On the Server". However, it only changes MyGameState->MasterNumber value when I click it from the Server window, and the text on Master button changes on both windows. When I click it from the Client window, nothing happens.
How can I solve this issue?
asked Mar 28 '15 at 06:00 AM in Blueprint Scripting
For anyone stumbling across this post...
Since the owner of the GameState actor is the server, any server function called through the GameState by a client machine will get dropped. See https://docs.unrealengine.com/latest/INT/Gameplay/Networking/Actors/RPCs/
By this logic you should never have any server functions in your GameState class.
If you want to send an RPC from a client machine to the server you must do this through a client owned actor, i.e. your APlayerController class
answered Feb 16 '18 at 05:44 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here