I am trying to create a simple multiplayer capture the flag game (first ever networked game) and i am stuck on a very specific issue. i have a server system set up, and the last step of the process is supposed to be that the player joins the level, picks a team from a widget button that spawns in the appropriate pawn at the correct spawn location and possess that pawn.
right now the only way i can think of to make this work is to get the server’s player controller ID with event PostLogOn and then pass that through to the Pick a team widget so the player can make their choice which then passes the team choice they made and the server player controller ID back to the game mode so it can properly spawn in and posses the pawn
as far as i can tell this should work except that i either get this error: Only Local Player Controllers can be assigned to widgets. PlayerController_1 is not a Local Player Controller.
and nothing happens, or i use player controller 0 and the code is run only on the host client (im using dedicated server)
so is there any proper way that i can get a local player controller from the game mode so i can pass information from the game mode to the widget and back out again?
ive been beating my head against this problem for the last week and am slowly decending into insanity so its entirely possible that i am approaching this from 100% the wrong angle
GameMode is Server only. Clients can never access it.
UI is local only. Should never be done on the server. Does not replicate anything (No Replicated properties or Run on server, Multicast or Run on client events).
Now to your question:
You want to a call a Client RPC (Run on Client event) in the player controller of the newly created player. When the player connects, you simply call PlayerController->ClientShowSelectionUI or w/e you call it. The clients UI will then run a function on the controller which is a Server RPC (Run on server), to send the selection back to the server, then the server can access the GameMode and process the selection (Spawn the player, etc).
Really hope this helps, tried to make it as simple as possible.
@TheKaosSpectrum: i guess my question now becomes ’ where should i be building mu blue print logic? if the game mode is server only, the Ui is local only then where can i build my stuff so that i can do client RPC AND Server RPC?
i… see? i guess my confusion stems from the concept that an entitry known as “player controller” exists that i can add BP nodes to. will have to find/add one for my game. till this point i have only known player controller as something i can call for stuff like possession and what not. is there a default player controler class hidden somewhere that is used for most of the example projects that i can look at? or should i just create my own?
I think that I might have found an answer to your question, maybe related to Kaos’s answer. I have been doing modding a game through the unreal SDK and maps on that game let you link a custom gamemode blueprint in my mod folder and to that I can link a custom player controller blueprint in the same mod folder. Maybe if you can find a way to link the game mode blueprint first?