Download

PreClientTravel is virtual, the only useful parameter is a const? How are we meant to use it?

I’m trying to make a Server spawn all of it’s players with a Default Pawn set by the Client. Basically, all of the clients might have different pawns specified as they Travel from the lobby to the map, and I want the Server to spawn the correct ones instantly. I DON’T want to use the GameMode’s DefaultPawn system, that’s only useful if every player has to be the same pawn.

So, I’ve overridden the GetDefaultPawnForController function several times and attempted to spawn the correct pawn. No implementation seemed to work, the pawn is specified by reading in from a textfile, but attempting to return the value from the Client didn’t seem to work at all, not with a Client function or anything. This has been 100% not cool so far, there doesn’t seem to be any easy or reliable way for the Clients to tell the Server what Pawn they want to spawn in as is. I’ve tried a lot of different approaches, this is the most recent attempt - which has yielded no result.

In the thread above somebody suggested that I can modify the URL that clients travel to, by adding additional parameters to it. Unfortunately, the only Virtual function in APlayerController for Clients travelling to the server using ServerTravel is APlayerController::PreClientTravel. The URL value passed in is const so I can’t change it, and it doesn’t look like PreClientTravel is called anywhere anyway…

The idea is that when a player joins the game and registers through “AGameMode::InitNewPlayer”, I can determine which Pawn to spawn based on the Parameter passed in by the Client as it travels to the server. However, there doesn’t seem to be any possible way to modify the URL on the Client side, to add the parameter. All of the functions are either non-virtual or the URL passed in is a const pass-by-reference, so I can’t modify it. ClientTravel would be the obvious place to override it, but it’s not virtual for some reason…

I can’t find any other way of passing values to the Server to determine which pawn to spawn for a player, which is decided locally by the client. The workaround would be for everybody to spawn in as a default pawn, then do a load of RPC’s to spawn the correct pawn for a given player and make them possess it. Since possession isn’t fixed until 4.8 comes out, that’s a brutal workaround and not particularly reliable either…