Hey!
I’m having some trouble with spawning characters.
My game is either singleplayer or multiplayer up to 4 people. Its local only, so no networking at all.
The amount of players is decided in my MainMenu Level, and then saved in a game instance.
When the actual game level is opened, it reads the instance to check how many characters it needs to spawn.
I have placed 4 PlayerStarts in the game level to prevent the players from spawning on top of each other, like this:
So far it works fine. If I play single player, only one character is spawned, and I can add players up to 4.
The problem appears when I try to remove characters from the game instance. If I play a multiplayer game with two people, two people will be spawned in a single player game as well. It seems like the max amount of players in one game is somehow saved, and somehow overrides the game instance. I have done several checks to ensure that the game instance is reverted to its original number. I’ve checked the number during runtime too, and it prints the correct amount of players. It almost seems like the PlayerStarts remembers how many players were playing, and spawns that amount. The game works properly if I close it and run it again.
The image above gets the player count and if the game is single player or not from the game instance.
If it is single, it creates one player character. If it is multiplayer (NOTsingle) it checks the amount of players and creates them.
The image above is how it loads the map in single player mode. The player count in the game instance is set to 0 (player index 0) when opening the single player menu widget.
And lastly, here is the widget for the multiplayer menu.
The events are widget buttons.
Again, the game instance doesn’t seem to be a problem, since it seems fine during runtime. I’m really wondering if it has anything to do with how I create the players or how the PlayerStarts are set up. I’ll take any help I can get!