My starting point is,
LAN on the same physical machine. Two packaged instances running development builds.
Created a session which has been successfully joined by a client. Evidence of that is both characters can walk around in the lobby level and replicate fine. The problem comes when we move from lobby to the next map.
The way I think I do should do this is with this code “GetWorld()->ServerTravel(”/Game/Maps/Arena1", true);" which is run from the server GameInstance.
This then calls PreClientTravel on both Server and Client: I have logs that state this.
The name of the playercontrollers during the PreClientTravel is PlayerController_0. I am expecting HandleSeamlessTravelPlayer and InitSeamlessTravelPlayer to be called on the server with both server and client playercontrollers, but this only happens with the servers local player. Strange also is that during this process on the client another player controller gets created from a network request, so now the client has got two playercontrollers updating. I guess swap player controller should be called somewhere. A little later on PlayerCanRestart_Implementation does get called for both player controllers and they are called different things now, one is PlayerController_0 and the other is PlayerController_1
I am guessing I have not switched playercontrollers on the client correctly at some point. I have overriden SwapPlayerControllers on GameMode but this never gets called.
Does anyone know what could be the issue?
In the child class’ overridden functions do you call the parent class’ version of the same function?
Thanks for answering.
Yes is the short answer, however I am glad you asked as I had missed a couple that appear not to be relevant to this issue.
I can see that both instances have loaded into the correct map so I added a debug key to spawn two pawns assigned to the playercontrollers on the server. Nothing appears on the client, although when I close the client on the server the associated pawn and playercontroller get removed correctly. As if the server is unaware of the clients problems.
Any further suggestions welcomed.
Well, It looks like you know more about network code than me, and I actually have done no coding except in Blueprint with Unreal. However, I can share a few observations that might help in your search for the problem:
- On the server, remote client’s Players all get a unique index number, just like local players.
- On remote clients, I guess the player controllers exist but those that don’t live on the client’s machine get index = -1, so you can only have player indexes 0,1,2,3 and -1 (unless you modify the C++ code for that).
- Because player indexes are all 0,1,2,3 and -1 on remote clients, you can’t match up client players with the server of that player by comparing player indexes - you have to go through their Pawn and get the controller that way OR the PlayerState’s unique player ID integer var to find the match (which is how I do it to decide which one is which when a player joins a game in the middle of a session).
Hope those help.
Thanks again for the reply. I feel it is something to do with the index or id. I will let this thread know if I sort it out. Cheers.