Role: | Lead-Programmer | |
Project Team: | 13 Students | |
Version: | Unreal Engine 4.26.2 | |
| ||
Tasks: | - Task packages created for other programmers | |
- VirtualSVN installation and configuration | ||
- Was involved in the structure of the level | ||
- Was involved in the structure of the weapon behavior | ||
- Character movement | ||
- Prototyping the multiplayer with servertravel from a lobby level | ||
- Creating a user-lobby with the steam core plugin | ||
- Everything around the part multiplayer like round time or respawn | ||
- Anti-Cheat architecture | ||
- Physical replication for example, when a booth for shopping collapses |
Tropical Gunfight was my first multiplayer game. The project was about a simple PvP game with repeating weapons. The game is playable online via Steam. This was made possible for me with the Steam Core Plugin for Unreal. The game is hosted by a player, which allows the opponent to connect to the host.
The game starts in a lobby where both players have the opportunity to familiarize themselves with controls and shooting behavior. The lobby has been designed according to the theme of a bay. When both players are ready, the host can start the game. The game is played until one of the players has reached three points. We took inspiration from the game Hunt Showdown, but we added a twist to the shooting. Thus, the player must manually repeat after each shot. This is to take the speed out of the game on the one hand and on the other hand to encourage the player not to shoot randomly through the area.
When the game is over, both players are shown the winner and if both agree, a new round can be started.
In this section, I will show how I implemented the Steam Core plugin into the project and how I solved a fundamental problem with the plugin. It is about the correct display of the number of players on a created server that are listed in the server browser. I will show how I became aware of the problem and how I tried to solve it. I also tried to make it difficult for players to cheat in the game.
For this purpose, certain guidelines must be followed so that abuse of the game is not possible or only possible with difficulty. For example, any kind of shooting behavior must always be done through the server so that cheating can be ruled out. The server must always check if the client can shoot. If this would not be the case, every client could decide for himself if he is allowed to shoot, no matter if he has enough ammunition or not. Furthermore, it would be much easier to implement a so-called Aimbot, because the complete logic is executed on the client.
Creating a session
In Unreal a session is created via the "Create Session" node. I give the session several parameters that allow me to read information from the listed game.
Here you can see the information passed to a session in the server browser:
The Make Map node is the only way to pass or display information about the game to the clients in the server browser.
Problem statement number of players
If you now connect to the server as a client, you will land in the game and the number of players in Figure 2 will be adjusted. Generally, the plugin is designed so that the game disappears from the list when the max player number is reached. But I did not want this, so I increased the max player number to three. But before connecting I check if two players are already connected. If both players are now in the lobby, the server can start the main game and thus initiates a so-called server travel. During server travel, the server takes over the map change and takes all clients to the new map. All resources from the old map are unloaded and cached, the new map is loaded and all clients are loaded into it.
The problem after this server travel is, that the information about the number of players is lost and the correct number of players is not shown in the server browser so that more players can connect to the game. To avoid this, I had to use a trick that allows me to read the correct number of players from the game and still be listed in the server browser. This problem already existed with the Advanced Session Plugin and even after extensive discussions with the plugin developer, I didn't come to a satisfying solution, because the information was still lost after the server travel.
My solution was then that with each created session also an invisible Steamlobby is created, in which the server also connected. Everyone who connects to the server is automatically connected in the background to the Steamlobby and leaves this as soon as he also leaves the game. Now I no longer directly read out the number of players on the server, but the members in the lobby that are not affected by the server travel.
Problem statement invisible steam lobby
The big challenge for me now was to find a way to create a unique lobby assigned to a specific session, so that players don't randomly join a lobby. And now the make map comes into play again:
After that I create an invisible lobby:
Eventually, I release the lobby to connect and let the server, which also acts as a client, connect (figure 6).
If the maximum number of players is not reached, the player can connect to the server:
As you can see, I only let the client connect to the server here but not to the invisible SteamLobby. This is because there were problems when two players connect to the game at the same time and thus both are in the game. To avoid this problem, I run another check just before the player is loaded into the server, and only if it is successful, does it connects to the invisible SteamLobby.
In the course of the project, I was confronted again and again with problems like this one, which made the complexity of a multiplayer game clear to me. Seemingly simple things become complex problems and that explains why these issues have to be dealt with away from regular gameplay. The whole topic of networking is a science in itself, with its own rules and procedures that have to be followed to master the fight against cheaters.
The project phase has given me exactly what I hoped for and I have used all my time to gain as much knowledge as possible from networking to having basic knowledge in the working world to go deeper into the matter.
Link to the repository: https://christian-brueckl.de:8443/svn/TropicalGunfight/
_________________________
Username: showcase
Password: showcase