Hey guys,
right now i spawn & possess the player pawn in the OnPostLogin event.
But after the seamless travel mapchange, the players are spawning as spectators (set as default pawn though) because the OnPostLogin event doesn’t fire because of the existing controllers.
So… how do i spawn them after map change?
Even in Seamless travel, most actors are destroyed because they live in the previous (now destroyed map) as you load the next one it (assuming you’re not ALSO using level streaming).
So that means things like PlayerState will be destroyed, then created when the next map loads, unless they are added to the list of actors to preserve into the next level. A few actor classes are added to this list by default, so you might not be able to use those for the technique I explain next.
So you can use BeginPlay on such a non-levelchange-surviving actor to check the possessed pawn class of the current player controller, and if it’s a spectator or not the one you want, you can spawn the one you want instead. Might be best to call a function in the Game Mode to make the selection and spawning happen at that point in the logic, but you can detect it from there.
But wait a minute, isn’t the Game Mode Actor itself destroyed when you leave one level and then enter the next?
So it might be as simple as saying there is no PostLogin event fired because in seamless travel the players don’t disconnect (logout), So you just have to make the PostLogin event call the same function that another place calls after seamless travel.
You want to override below function in ur gamemode for seamless travel
/**
* Handles reinitializing players that remained through a seamless level transition
* called from C++ for players that finished loading after the server
* @param C the Controller to handle
*/
virtual void HandleSeamlessTravelPlayer(AController*& C);
Hello. You need a different Player Controller and a different Game Mode when you travel to another map.