How to store my GameMode's array of PlayerControllers across seamless travel?

When using seamless travel, events like OnPostLogin don’t get called in the new GameMode, but my PlayerController array - a variable in my gamemode - doesn’t survive the trip either. How do I store this array so the new map’s GameMode can access it? I was thinking of storing it in the GameInstance, but I’d probably run into some type issues - I’d be storing LobbyControllers when the new map expects GameplayControllers.

I know the actual playercontrollers are converted to the new type by the engine during seamless travel. How do I get the new array to populate my array? Can I convert the old controllers to the corresponding new ones?

Normally (in the lobby), the array is populated as players log in, using the given controller from the OnPostLogin event. Obviously I can’t do that with seamless travel.

Update: I read that I should get the controllers from the GameState’s array, but this doesn’t seem to work: the cast fails. All the controllers in the gameplay map should be subclasses of GolfController.

Off of the array element in the ForEach loop, cast it to your PlayerState and from there you should be able to grab the Player Controller variable. That Get Instigator Controller I don’t think will return the controller you are looking for. Check out this on the answerhub: https://answers.unrealengine.com/questions/425091/how-to-reference-each-playercontroller-from-gamemo.html

“your PlayerState” - all my gamemodes are using PlayerState as the player state class, and there is no “Player Controller” member. How do I get the controller from it?

I also tried this, and it seems like it might work, but it crashes the game unless I add a delay before doing this in BeginPlay. How do I know when it’s safe to poll the playercontrollers (and why can’t I do it immediately in beginPlay)?

[EDIT] After some more testing it looks like my solution was iterating over the old playercontrollers (or something), so the clients’ ones were never going to be valid if they were retrieved right after BeginPlay (I also tried storing them in an array).

It seems like I need to poll all the playercontrollers and see which ones can’t respond, but I can’t actually store the ones that don’t respond to know to try them again until they work… Do the indices stay the same? I’m getting weird **** like “-1” from Get Player Controller ID so I don’t trust them very much. There are a bunch of super kludgy ways I could do it, but I’d prefer a good clean solution, but then if I want clean solutions maybe I should just write some C++ anyway.