I’m running some tests for my understanding of when a player joins a map with a custom GM, and on postlogin(), logout the uniqueid from the passed in NewPlayer->PlayerState->GetUniqueID() which gives me a certain number on the server.
In the client custom GameState for this map, on the function AddPlayerState which is supposed to add the new player to the PlayerArray upon joining the map, I logout from the passed in PlayerState->GetUniqueID() which gives me a different number than what is logged on the server.
I even, set a 5 second timer to log the client id a second time to see if the server/client have replicated properly, and tested on the same machine both server and client running the null subsystem and the different numbers still show up. This is testing with the first player joining the map.
I’ve read that sometimes the PlayerArray can be zero before the GS has had a chance to initialize, but I am not getting zero…I am getting a number that is different from the server…I’ve also tested from the PlayerArray[0]->GetUniqueID().
I thought the UniqueID was supposed to be a replicated number maintained on both client and server…I was expecting it to match. Does anyone know why it doesn’t, or am I missing something in my limited knowledge thus far?
UniqueId is basically the index into an array of whatever UObject type you created so depending on when objects are created (and how many), the value will be different between client/server. It’s not replicated and values are re-used as objects are deleted/instantiated.
You really shouldn’t be using it for anything as the value will differ even between game sessions on the same client depending on the order of operations the user takes.
Sorry for the necro - just coming across this having spent a while trying to work out a way to get a unique but persistent ID for a server and/or client. Given what you say, the description is somewhat misleading:
virtual FUniqueNetIdPtr IOnlineIdentity::GetUniquePlayerId(int32 LocalUserNum) const
Gets the platform specific unique id for the specified player
“Platform specific” makes it sound like what you want it to be: per-platform, per-user persistent ID, but it’s not quite that. In my case I think I’ll have to make a steam-specific (and if I go EOS, a separate EOS-specific) set of code to identify a server/client - this is for the naming of save files.
I’ve been searching and reading on this on and off for a couple of weeks now but not found anything relevant, apologies if there is something I missed making this necro inappropriate.