Developing Multiplayer
- Treble Thieves
- 3d
- 2 min read
Updated: 1d
For Treble Thieves we wanted to have some form of multiplayer. We landed on Unreal Engine’s Session System. Unreal Engine’s sessions are probably the easiest way to get two or more computers connected over the same network but that does not mean we didn’t face any challenges. Under the hood, getting the computers connecting to each other is rather simple when you look at a working example, but getting to that point took a lot of trial and error to get just the right set of blueprint nodes and settings to successfully make the connection between computers.
Getting two computers connected takes very little. Unreal Engine provides multiple nodes that will do 99% of the work for you. The nodes you’ll be using most are “find session,” “join session,” and “destroy session.” “Find session” is straightforward: give it your player controller, the number of sessions you’d like to see, and if you want to use LAN or not and it’ll spit out an array of all the sessions it could find, up to the amount you set. ”Join session” is even simpler, requiring just your player controller and one of the sessions from the array the previous node gave you. Now when I originally set things up, I didn’t really care if there were going to be multiple servers, so the game used to just connect you to the very first session it found. Obviously, that wasn’t going to work long term, so down the line I made a widget that would be created for each session found to give the player the choice of what session to connect to.

The last node you’ll need to get well acquainted with is the “destroy session” node. This node behaves differently depending on whether the person running the node is a client or the host. If you’re the host of the session and run the node, it shuts down the session, booting everyone back to the main menu. But if you’re a client, it simply makes you leave the game and returns you to the main menu.
An obstacle we discovered was a bug when the host ran the “destroy session” node. If the host destroys the session without the clients being prepared, visually nothing is wrong but when any of the clients attempt to join another server it will always fail. We got around this by detecting if the host is the one attempting to quit, and if it is telling all the clients to run the destroy session node. Otherwise run the node like normal to quit the game. Doing this allows hosts to start new servers and clients to join servers without needing to restart the program.
Overall, the session system can be difficult to get working when you’re first starting out but once you get past the initial hurdle it tends to work just fine without much needed maintenance. I would absolutely recommend it if you’re looking for just a simple LAN connection between computers for your game.
Comentários