I’m currently working on a poker game as a school project and I’ve encountered a problem I’m struggling with for over a week now.
When starting the game, player can choose to host a game or join one, that moves players to the lobby, and everything is fine, but when every player is ready and the host starts the game, inside the game scene, when the players start taking their seats, the server sees everyone, but the clients screen remain unchanged. First I thought this might be some problem with replication, and while this is still a possible problem, I’ve found this inside a clients log:
Based on the first few rows it looks like the clients have some problem joining the game session, and they can’t run the UpdateSeats function from their PlayerController blueprint.
I’m pretty new to this whole thing and trying to figure out what could be the cause of this with very little success.
If you have any idea what could cause this please share with me!
I’ll happily provide any information/blueprint pictures or anything else needed!
At a glance it looks like you are trying to get the GameMode on the client. When connected to a server the GameMode only exist on the Server and Clients will never be able to get it. The GameState class is where the server lets clients get information from as it exist both on Server and Clients.
Also remember that GameInstance can’t have any replicated variables since it only exist locally.
Ah, I see, I’ll check that out, thanks! Unfortunately I don’t have a GameState set up, because the Blueprint Multiplayer tutorial from Unreal’s youtube channel doesn’t use it and I set up my project based on that. Later I found a post here which mentioned multiple problems with that tutorial, and now I’m struggling a lot on those points.
So if I have a variable in my GameMode which I want to use in the PlayerController I should put it into the GameState instead, right?
The server has all PlayerControllers while each client only have their own PlayerController, this enables the Server to communicate privately to each client and the client can communicate with the server privately.
The GameMode (Server) could then call a client PlayerController and on the PlayerController make a RunOnOwningClient Event or Set a replicated variable that the client can use.
GameState should be used for GameMode stuff that the Server wants to share with all Clients.
PlayerState should be used for replicated variables that are unique for each Player and has to be readable by other Players eg. Score and Ping.
GameInstance can’t replicate anything and should only be used for local persistent events like Show Menu.
Pawn/Character when owned by a player can do it all. RunOnOwningClient, Multicast to all, RunOnServer from the owner and set replicated variables that can either be replicated just to the owner or to other clients.
So far I’ve only used the GameMode and PlayerController based on a tutorial, thanks for the plus info!
I was able to solve the errors, somehow I called the GetGameMode->CastToGameMode etc… part on the PlayerController, which gave me these errors.
Now this is my runtime log:
After the “Test2 is after init seats” part the client should clear a vertical box’s child and populate it, but still nothing happens on the client, only the server can see the changes.
This is the part I’m struggling with for over one and a half week now. The strings are showed, but afterwards nothing happens and this drives me crazy. I’ve tried switching functions replication mode, running them elsewhere, but no success so far. And the logs don’t give anything about it, just the “No game present to join for session (GameSession)” message. What could cause this?
Afterwards if I understand things right, this still should be some replication issue right? Maybe I’m just trying to redraw/populate the GUI in a wrong way, is that a possibility? What I’m doing is that I have a vertical box, inside a button with a text, when it’s clicked, the vertical box runs a clear children, and puts in a PlayerPlayer widget which contains some info about the player who clicked the button.
But if the GUI redrawing/populating would be bad, the server shouldn’t see it working right?
Sorry for the lots of answers, I’m losing my mind over this and I would bet that in the end it’ll be some minor mistake which I simply can’t recognize.
After this is the part when I closed the tab, so there’s no more runtime log after joining the game (SeamlessTravel).
So you are working with a Widget on the server? Widgets only work locally and can’t replicate anything since the Server doesn’t have the individual client widgets objects to use for replication. The screen icon on the CreateWidget node indicates that this node never runs on a Server.