Angus Dale

Games & Graphics Programmer

Network Programming


The requirement for this project was to create an application with two or more networked objects using either TCP or UDP. I created four player PVP arena game using UDP with .NET sockets, employing a client-server architecture. I used clumsy to simulate poor network conditions in order to test the data transfer systems I created. The project received an A+ as part of the CMP303 module.

Engine: Godot

Language: C#


More Info ↓

To account for the delay of sending and receiving messages, I used linear interpolation to predict the position of other connected players. It was also important to use UDP for the player movement, as only the newest packets are relevant.

Due to it being a PVP game, it is important that the bullets get fired are in the correct position. I calculate a temporary speed for the bullet to travel at in order to catch up to the sender’s bullet. Gif shows a bullet hitting a wall at the same time despite a 0.1s delay.

Handshake System

I developed a handshake system that would flag certain packets as ‘important’. These packets would get resent if no confirmation message was received. This was only necessary because the game was built entirely using UDP. I then needed a way to prevent the handling of duplicate packets in case a confirmation message was lost. To address this, each client holds a list of the most recent ‘important’ message IDs which it can compare against when a new packet arrives.

Create a website or blog at WordPress.com