How would you implement an online multi instance of dungeon game with character progression?

Basically the game flows are

  1. New player create account to get his login name and password.

  2. After login, new player create character (choose character race, class and etc) and save it. New character will start at level 1.

  3. With created character player can go into starting town (this is a big town where all players will see each other to socialize or find team member)

  4. One of the player in town can form a group of 5-10 player to enter a dungeon. So multiple players can form multiple groups into multiple dungeon instances.

How would you implement a game like this in UE4?

Well, given that we’re still learning, this is how we do it …

  1. We have created a C# launcher that connects to a MySQL database and creates the user account and the default info. The player logs in through the launcher.

  2. <Not done this yet, but there are tutorials, example projects, and even a Marketplace asset for character customization.>

  3. We have a dedicated UE4 server that runs the first zone map. We don’t yet have a town, but are working on something in the vague shape of a town.

  4. We have a social system asset purchased from the Marketplace that includes chat, grouping, guilds, messaging, etc. We have a test dungeon on another server instance (same physical server) that can be entered (by zoning) from the first map.

While our implementation is incomplete and not very efficient at this point, it does show that all of the things that you want to do, with whatever quality that you wish to achieve, are indeed possible with UE4.

One fact that you should be aware of (if you are not already) is the limitations on UE4 dedicated servers. The largest number of simultaneous player connections that I have read about is 147 and it seems that there is a default limit of 64 (this may have changed.) With basic UE4, you should not expect to get more than 100 players per server and perhaps much less.

Did a quick test in UE4 Editor out of curiosity… And indeed the Python thingy sounds plausible :slight_smile:

import unreal_engine as ue
import pymysql.cursors

# Connect to the database
connection = pymysql.connect(host='localhost',

    with connection.cursor() as cursor:
        # Read a single record
        sql = "SELECT `id`, `password` FROM `users` WHERE `email`=%s"
        cursor.execute(sql, ('',))
        result = cursor.fetchone()

I think there are many viable way to communicate with the database from UE4, embed Python is pretty neat though like what you have demonstrated, good job!
But I can’t find a proven method to allow multiple group of players to enter multiple instance of my game dungeon. From my research so far, this needs to either

  1. Spawn multiple UE4 server instance that runs in multiple virtual machine with one single port open i.e 7777.
  2. Spawn multiple UE4 server instance that runs in single machine with one server instance using a particular open port i.e. instance1 7777, instance2 7778 and so on. This would cause problem for players, they will need to manually open a port in their pc and how would they know which port to open???

This is in theory though and there isn’t any tutorial or showcase I can find to demonstrate how this work.

  1. Ok so you have a UE4 server instance to runs the first zone map and it is limited to only 64/147 players inside at the same time. I guess we could spawn another first zone map to host another 64/147 players and so on, though this two group of players would not be able to see each other but I think it is good enough or we could allow players to jump into different instance of first zone map.

  2. Let’s say now you need to test 2 dungeon. So you spawn another test dungeon in the same physical server by means of a virtual machine with one open port or just multiple UE4 server instance with multiple port 7777, 7778 and so on? Which way you will go for and if multiple port how do you handle player’s open port in their PC?

How about the communication from the dungeon instance with the game database to store player’s loot items and XP? Like when a player inside a dungeon loot an item or gain XP.

I think what you are looking for is a “Instance Matching Maker” ?!
Like in this game, that I played for a while, scroll to Instance match

You have to make a ‘master server’ which will collect players that are looking to join an instanced map. Once the group is formed, the master server launches the new server process on demand and map travel the group to the new server instance…
This “matchmaker” stuff is very complicated, I have no idea how that work.

Sort of, but for a start I just need to be able to allow group of players to enter a new dungeon from town.

These kind of games usually asks players to open a port range, instead of just one port.
Like 7777-8080… Then in case a machine is full with instances you’d have to direct players to another server machine starting from 7777 again. (or deny dungeon entrance, like I’ve seen before)

For the Unreal dedicated server, you can specify the port and map at launch. We use a batch file to make this simple. For example a batch file could have the command: “c:/unreal_server/gameserver.exe Map1 -log port=7777” The next server instance run on the same physical server would change the port to 7778 and so forth. For the dungeon zones, we simply specify a different map on the new server instance, i.e. Dungeon1Map. To zone between the main map and a dungeon, we use a trigger box and a function on the client that uses the OpenLevel node. This disconnects the player from the landscape map server and connects him to the dungeon map server. The port and ip address are set as variables. You could set these in any way that suits your design.

For db server communication we use the Sockets plugin and server that is available on the Marketplace. Inventory, stats, location, and etc storage is all handled by communication between the UE4 server and the socket server. Many use the VaRest plugin that is also available on the marketplace.

I would suggest that you investigate the MMO-Kit (about $100) that is discussed here on the forums. Much of what you want to do is built in to that kit and at the very least it would provide working examples for your project.

I think we could open the port range for players during game installation, that should be acceptable.

Good practical info! I will go with this way for now. Thanks.