Networking/Multiplayer Experiments

Network programming and multiplayer games is an area I have a particular interest in.

Below are a couple of networked game experiments that I created in order to familiarize myself with network game replication.

image

NotPong

NotPong is a simple multiplayer version of Pong.

The objective is to get the bomb to explode in the other player’s part of the ‘field’ or their ‘goal’.

It was made in Unity and it uses Mirror for networking.

It uses a client-server model with a custom NodeJS backend utility managing game server instances.

Architecture

To play a game, one of the players creates a lobby uniquely identified by a 5 character code. They then give the code to their opponent who uses it to connect to their game.

On the backend, when a player creates a game, their client makes an API call to a dedicated server which spins up a new game server instance.

The server instance binds to an available port within the preconfigured port range and is assigned a unique lobby code. The code is then returned to the game client to be shared with their opponent.

When the opponent enters a lobby code, their game client performs an API request passing the lobby code which (assuming the code is valid and the lobby is still running) returns the game information (primarily the game server port number). The game client then connects to the server and the game begins.

The game server is configured to shut down when an opponent has not connected to the game after a period of time and after the game is finished. Upon receiving the ‘close’ event, the matchmaking API kills the game server PID and removes the lobby code from the ‘running’ games list.

Server Hosting

This was a learning project so the servers are no longer online, and also the reason why this didn't use a peer-to-peer model which would make more sense for a game like this.

The game client also had a concept of 'regions', with players being able to select a region to connect & create games in.

At the time, the game had servers hosted in 3 different regions. (US, EU and Australia)

Untitled Racing Game

URG was a prototype of a multiplayer isometric racing/karting game, inspired by Biker Mice from Mars.

Unlike NotPong, it used a peer-to-peer model with one player hosting the game and other players connecting directly.

The idea was to have multiple characters with their own unique vehicles and weapons/abilities.

Description

  • Personal

  • 2021