Strange GameMode behavior after Open Level


I work on a local multiplayer game, and I’ve created a map for the menu and a map for the game. Each have there own GameMode. I also made a Game Instance to save info between map (like score, skin of player, ect…)

For my exemple, I have 3 players who want to play, they have to press A on there own controller to validate them-self and add a player in the Game Instance. The first player have to press start button to launch the game map. The game map launch well, but there are 4 pawn instead of 3. The fourth not follow the spawn rules made in the map GameMode (the GM just get the number of player in the Game Instance and do a For Each Loop to add the player pawn where a Player Start is placed on the map, all tagged to avoid collision ect…).

Now, if I set manually the number of players in the Game Instance and launch the map directly in editor, all work has expected: 3 pawn appear, well placed, no more fourth pawn.

Do I miss something? Some value have been send from one Game Mode to another? Even if they are not the same?

Thanks for your help.

EDIT: I tried to unpin “Event BeginPlay” in my game map GameMode and the not wanted pawn spawn anyway!

Are you spawn each player pawn manually? If so change GameMode Default Pawn Class to none.

Thanks for the answer,

I actually change my spawn method from using Default Pawn Class (by using Create Player) to SpawnPawn + Possess and I don’t have any problem anymore, and I, well, have to set Default Spawn Class to none to do that.

But, after further investigation yesterday, I have found an explanation: in my menu map, I create 4 players and so 4 controllers and, I think, the controllers have been moved from Menu to Game Map when I do an Open Level from Menu Map.

To follow map change. Open Level with ?Listen option and ServerTarvel.

Travelling in Multiplayer…ing/index.html


It’s not an online/lan game, it’s a local multiplayer game (I’ll probably add an online mode later, but for now, I just want the local mode to work well)

If you set manually number of players and it’s working fine than it’s problem with your “player counter” variable or in For Each Loop (note that the first index is 0 not 1 if you are using array somewhere, so maybe that’s the problem).
However, you can debug with “Print” node and output Player number. If all is correct try to output For Each loop to see what’s going on in the loop.

I’ve verified evrithing with print string, and all look good, every problem I met come from the travel who come with controller.

If I launch the map from the editor, everything work fine (and I have to set player number manually for that, if not, it stay to 0 and nothing happen, normal), but if the map is open from another level with already pawn spawn (with controller), the problem happen.

So when you open gameplay map directly and set number of players in the game instance it’s working fine, right?
Your gameinstance hold the player number that are “ready”. I do not see what can cause this problem. Maybe you could share some BP screenshot?

Try this: in your gamemode disconnect pins where you create/spawn player and instead print PlayerNumber output from Gameinstance.
Start game with Menu and see what will output when the first player start the game (when the new map is opened).
And one more thing: Are you using splitscreen or shared camera for local MP?

I don’t understand what cause the problem too, but, I already perform some test like you suggest:
-The number of player is the good one when I launch the game map from menu map
-If I disconnect the pin that create/spawn player, I still have 4 players created but uncontrollable (from the map menu, I guess)

I use shared camera but, I plan a splitscreen gamemode in the future, so I have found a c++ code to switch from one to another, and to make it work, I have to activate spitscreen in settings and deactivate it in the BP

If there are 4 players (and you want 3 for example) without spawn function than it’s probably problem with map setup and game mode.
Try to disable auto possess at your character, also try to set Spawn as observer in your game mode (but I don’t think this will help).
Why you do not use “Spawner actor” instead of Player Start? Just create new actor/pawn, place it on the map where is your Player Start locations (and delete all Player Start targets).
In your game mode use Get All Actors of Class (for spawners) to get all locations at begin play. Finally, you can “Spawn actor from class” (your character) in for loop by using “Spawner” actor “transform” and possess (pass/give controller). Like this you can control how many players will spawn and give specific controller for each player (instead of “auto spawn”)

Before meeting the problem, I actually juste spawn default gamemode pawn and set controller automatically. Since I can’t found solution to avoid more than the defined number of pawn spawn, I use now your suggestion: using “Spawn actor from class” and set none in Game Mode default pawn (if I set anything, it will spawn 4 time, even if my gamemode BP is empty but only if come from another map with already 4 controllers, if I call the map from editor directly, nothing strange happen)

Thanks for your help!