Hey @MarsMiner,
1) But if you were making a game for deployment and you wanted some kind of system so each player would have a home screen, and from there they would host a server/ join one and stuff like that. How would I make it so connections happen in-game?
Basically, you’ll need a third agent–the so-called “server”–to make the communication between your players happen.
2) Also - Do people playing together have to be on the same LAN? How does all that work?
I needed to skip to this question to make the first one clearer.
You can do the multiplayer system however you like. It can be LAN, it can be session-based, it can be MMO, it can be P2P–the sky is the limit.
Fundamentally your players will communicate to each other, as said before, through a server. You can make they host for their own, or you can build a dedicated server to host the game for them. The important for the game to happen in the multiplayer fashion is that a server is accessible through an IP and Port.
I am going to give you a practical example of a LAN scenario, where your game is ready and has a Host Game
and Find Game
button on the home screen.
Player 1: she/he opens your game and taps the Host Game
button. After this, a lobby is created for this player to wait for others to join and start a session. At this very moment, this lobby must be discoverable for other players to make them connect into Player’s 1 lobby. To make this lobby discoverable, a server must be created under the hood. The local IP usually is 127.0.0.1
and in Unreal’s case, the default port stands for :7777
.
Player 2: she/he opens your game and taps the Find Game
button. After that, you can make your game search for servers with the 127.0.0.1:7777
IP and port. If a server is found, then connect Player 2 into the lobby of that game.
These are the important parts of the given context:
- 1) The creation of a server exposed by an accessible IP and port.
- 2) The reach of these properties (IP and port).
Look how interesting all this is: for a LAN game, all you have to worry is to create a server. All computers connected to the same network will be allowed to access it out-of-the-box. But, if you want players connected to a different network to join a given server, then the second important part comes in–you need to expose the IP and port and make them accessible in order to allow outsiders to connect into that given server.
As you already know, this is a broad subject and won’t be possible to cover all the variables surrounding it now, but this is the necessary idea you have to have to move forward.
To summarize: you have to create a server, dedicated or not, and expose an IP and port and distribute these to others in order to have them playing together. They don’t have to be connected in the same LAN, but depending on what you’re trying to achieve, it’s required that you take the proper actions.
I’ll leave you with this great Compedium, written by @eXi, in case you haven’t seen it before. I have no doubt it’ll, soon or later, come in handy.