Where do PlayerStates get Initialized?

Can’t find this to save my life… where do the PlayerStates actually get created and assigned to PlayerControllers? I’m trying to Cache my custom PlayerState in the Controller as soon as it’s set.

EDIT: NVM Found it, it’s in ‘FindInactivePlayer in AGameMode’. Unfortunately because it’s set directly rather than through a function means I have to override this instead and do some copy-paste. Would probably be better if PlayerState was private / protected with accessors.


I wanted to suggest maybe overriding AController::OnRep_PlayerState, but curiously that function is not called manually in FindInactivePlayer after changing the PlayerState. I thought calling the OnRep_ function after changing a ReplicatedUsing variable was recommended so that the OnRep_ function also executes server-side. It isn’t called there unfortunately.

Yeah I found actually that even putting the code in ‘FindInactivePlayer()’ didn’t actually work anyway, so my guess is it’s not being properly set there either.