Having problems spawning Players in Multiplayer

I’d love it if you already know how to put a server list/join together. Menu and all. I’m currently trying to convert the one from the Multiplayer shootout to my game.
It’s not going smoothly for me. I don’t understand all of the things it’s doing so it’s difficult. But I do think all of the needed items are there.

I have a big BP Multiplayer System in work for the Market. I will comment it as much as i can. Maybe this will help
some of you, but it will still take some time to complete. Need to rework some parts.

Meanwhile you can ask me question if you want.

Makes sense… I wouldn’t want you to give out your product before its ready. Though if it’s reasonably price even if I get to where I need to be now with your help (even in PMs), I’ll still make a point to support you when you release it. Esp considering I only really need the matchmaking portion at this point.

I’ve got my maps, characters etc all working right in MP. Killing each other works, effects are multicasted properly etc.

What I want is, when the game starts:

The main menu looks like any other with a cool background
You can play the game solo (offline) (which I can do fine with an open level button)
This is where I need help:

Or you can Find multiplayer games currently happening.
Or start a game of your own and wait for people to join (choose map, game type, amount of players)
The “waiting room” would just be a small level with some target practice(whatever) while waiting.

Right now there are only four characters to choose from. I don’t want anyone on the same team to have the same character. (the opposing team will always look the same to everyone on the same team. i.e. swat memebers or terrorists or clowns or whatever…i.e same mesh for now…) So each team can have duplicate meshes but the other team wont see them anyway.

(I have already got the character select working in such a way that the char is spawned and the user posseses them. They end up in their own game though. Which brought me to this tutorial on how to keep them i the same waiting room)

So once you choose a game to join, you choose a character thats left(hasnt been chosen) and it drops you into the same waiting room as the rest that are waiting, until the game mode (see below) criteria is met and the game launches (to selected map)

I want the following game modes

Death match


Obviously if I get 1 working I can copy that.
I’d prefer to have a dedicated server running where it handles all created sessions. The host simply launches the game when ready but the true host is the dedicated server. Don’t know if this is possible though.
I’d eventually like to add the functionality of having each user have to authenticate against a SQL DB (or create a free account) or something before being allowed to create or join a game.

Currently I can set x amount of players and just hit play and all four spawn into the same map… and can shoot and kill each other.
I’m trying to set up the way to create the game type and enter the waiting room… and the interface that others can see that theres a game waiting there.

Does this make sense?

Yes it makes sense, but the DB thing won’t work so easily without C++ or at least a plugin.

What my Project will contain:

  • Host Server with Name, Amount of Players (GameMode selection)

  • Waiting room is a Lobby with max 4 Players (you can alter this, but this is just my small example)

  • Each Player has a Ready button and can choose a Player (at the moment you can choose between different colors of mesh).

  • I also have 2 Teams, Red and Blue
    – I am planning on making 2 GameModes. One for TeamDeathmatch and one for Deathmatch
    – Although the Game itself won’t have any GamePlay related things, because this is about networking and UMG, not gameplay

  • The Server (here it is a listen server) can kick the players and start the game as soon as everyone hit the ready button

  • A loading screen
    – Network error, so you can see errors popping up with an ok button if something happend (connection lost, kicked from server…)

  • Inside the actual game you have a scoreboard for either both teams or all players (depens on GameMode)

  • You will have a chat (need to implement it) and you have a Menu where you can change your PlayerName (you can change it in the options of the main menu too)

  • You can also add players to your group (Sending invites etc). But this is just a showcase. This shouldn’t result in a game. It is a showcase on what you can do with BP, network and UMG

And if i come up with more things, then i will add some more.

The point here is, that i want to make everything as modular as possible. So you should be able to strip of the Chat system or the scoreboard without thinking about the rest of the
features. Some of them will share certain variables. For example the PlayerArray. But i will try to comment everything and give the different comment box colors.

The pack will cost around 20€ i guess. Depens on how much time i will need to finish it.

For your specific game:

Try to use “Create Session” and “open level” together for hosting. Make sure you open the drop down of “Open level” and add “listen” to the options.
Now you can check the session with “find sessions”. Keep in mind that you can’t find online game until you have a subsystem like steam or you own master server.

If you want to have a dedicated server that has some kind of admin, you would need to dig into c++ i guess. You can compile a dedicated server, but by default, every
client is the same. So you would need to mark him as an admin somehow. I would rather go with the listen host way i’ve chosen.

GameMode will be no problem. I guess you can change the GameMode runtime. But i will need to look this up.

Too have the possibility to limit players from taking the came character twice, you need to have a center instance where you save the chosen character. Best would be on the server.
For example in the GameState. You would need to send a request from client to server, he checks if the character was already taken and either gives the player a go or a stop for taking the character.
Then you would need to save the chosen players either by a savegame or in the gameinstance class, so they persist throughout a map change.

I can’t go into much detail here, otherwise the whole project wouldn’t be necessary :smiley:

thanks eXi… thats a good starting point. I’m working through it now.
I’ve managed to get the search for LAN sessions working. Though its not reporting back the correct data in the server list, joining the game works. However, my second player always spawns at 0,0 (under the map). Not at the player2 start point.
When I launch the map without using the join session thing, both players are in the same world, player1 spawns at the player1 start but player 2 spawns at 0,0 still. If I manually exit player 1. Then player2 spawns at the player1 spot in their own world.
Trying to figure out whats going on there right now.

EDIT: I didnt have default pawn class set. I though that didnt need to be set when spawning and possessing but apparently it does… since it never seems to spawn my second player. Bleh.

So there’s no way to do public WAN games search without using C++? Unless you specifically know the hosts IPAddress? That kind of makes me sad right now.
Does using the Steam SDK make public matchmaking simpler?

Probably spawning them wrong. Are you sure they are spawned at all? If the spawn fails, you will be left at 0,0,0 with an unmovable camera.
Does your Spawn node has this “Fails on collision” or what it was, selected or not? Maybe the Server does not spawn them.

Or you are trying to spawn them although the Controller isn’t ready yet. Are you using the “PostLogin” node from the GameMode or where are you calling your Spawn thingy?

I’m definitely doing it wrong.
I’ve made quite a bit of progress since my last post.
I’ve learned a lot about UMG stuff.

I have my character and map selection stuff down pretty good. The single player launches like a dream with the character selected and the map…etc… awesome.
Now I’m trying to get the multiplayer to work. The selection logic in the menus is no problem now, but I’m back at my spawning character issue now.

Player1 always spawns at playerstart node that has tag player1. No problem. The others start as you mentioned, no camera movement. I copied and pasted portions from the multiplayer shootout game from Epic. I don’t know if this is good or bad. I loaded the shootout game again though, set default pawn class to none and launched their game, and it looks like the same behavior happens. So I guess theirs needs default pawn class set for the second player too.

Any help with this would be appreciated. I can’t test anything further til I get my characters into the game together. I tried putting a break on the player 2 respawn event… but i guess that bit never seems to run at all.

I’m going to move my issues over to a different thread on the answerhub. I don’t want to hijack this thread anymore. It’s for the tutorial.


Hey, there, i moved this to a new thread in the Blueprint Section. I don’t want to spam his tutorial post.

Oh right

I forgot you had that power.

I’ll mark the answr hub thread answered
And delete the last post there .

Did those pictures show up for you here?

Yeah i see them here, but i have no idea how i can access attachment pictures :X Can’t open them.
Would you mind editing that post and using direct links to the pictures?

EDIT: Oh nevermind, rightclick + open in a new tab works.

EDIT2: I will quickly show you how i spawn my players in multiplayer, ok? Gimme a sec for a screenshot.

EDIT3: The “EventPostLogin” doesn’t ensure that the PlayerState is valid. You are using it directly. Don’t do this.
Only use the PlayerController. If you want to do something with the PlayerState on BeginPlay, then use the BeginPlay of it directly.

If you destroy the controlled Pawn, make sure that it is valid. When the player first spawns, it has no controlled pawn. Make use of the “IsValid” node!
You are getting the ChosenPlayer on the GameInstance of the Server. You need to get it in the “ClientPostLogin” event, not the respawn event. And pass
the number with an input on the Respawn event.

The rest of your setup is to detemine if the Player is the first one or the second one i guess. More players are always Player2.

Try to make a simple setup like this first. Better would be without the GameInstance part. Try to spawn the two players. If this works, add the next part of the system.
Don’t do all at once. Also i wouldn’t use that much of the Shootout game. Better try to recreate it, so that you learn how it is done.

I think you can set a default pawn in your gamemode, and it’ll spawn that pawn. So have your player actor there and then just have the server teleport it to where it’s supposed to be and setup all the other things.

Correct, but this way, you can’t choose between multiple characters at the beginning. If you want to spawn one of many different classes
and you don’t know which class before the game is running, then you need to set the DefaultPawn to “None” and create your own Spawn logic.

I guess that’s true depending on how the system’s built. If you want to be able to switch classes during the game for example, it’d probably be easier to just spawn a generic actor and then tell that actor which class he should be.

Or just spawn a different class. Otherwise you would need to put the complete logic of all different classes in one. A baseclass for things they all have in common.

Is all of that in the custom GameMode bp?
I have some of that in the GameMode and some in the custom player controller. I’m not sure why the example game separated certain parts?

No, the Client PostLogin is inside the PlayerController. You can see this on the Event that is called in the GameMode.
The upper part of the GameMode Sequence is not interesting for you. Only the lower one.
The other pictures is from the PlayerContoller.

You sperate this, because you want to call the Server Event ON the PlayerController, so that he will posses the Player that was spawned.
Both of this must happen on the ServerSide when doing Multiplayer. Otherwise no one would see the spawn Character and the Posses wouldn’t work
(because a client is not allowed to posses anything from the server).

I have been have the same problem. Tried to build quick version of the multiplayer shootout game. Every thing seems to be working fine except player spawns. The client spawns at the player start, but the host ignores the playerstart and spawns at world origin. Ill post if I find out what Im doing wrong.

I want to hug you now. :cool:

It’s working! With the char chosen logic from gameinstance as well, right away!

  • I moved the respawn function from TPGameMode to CustomPlayercontroller but that gave the same results
  • I Moved the ChosenChar to the postlogin function and piped it into the RespawnFunction node as suggested
  • The magic seemed to happen when I added the IsValid GameInstance before casting to GameInstance
  • I also didnt know about the getClassfromstring node…(doh) I used integers… lots of duplication this way… i’ll make that more efficient now

Awesome. Thanks for all the help so far. I can now start building and testing the MP menus I want!

I’m glad i was able to help you! (:

One of my characters sort of launches into the sky at spawn though… im guessing because it spawns ontop of another. the checkmark on spawn whether its colliding doesnt change it.

The player whose character launches… is actually grounded… when I move him, he ‘appears’ int he proper spot to the other players. So its really just cosmetic at launch… once the player moves its ok. but still strange.

EDIT: I just added more player starts rather than have all but first spawn at the same place.