Networking Project
A tank game built with Unity Engine that uses networking for simple online multiplayer gameplay.
University Assignment | C++ / C# | ~ 2 months
-
Winsock / .NET Sockets API
Both APIs are used for creating sockets and to establish a connection between Client (written in C#) and Server (written in C++). -
Server-Client Network Architecture
The information between all clients is synchronized using a server that receives information from all clients and then redistributes them to the rest. -
Asynchronous I/O
Allows the program to keep continuously running instead of waiting for new input by using Event Callbacks once information has been received from the stream. -
Client-Side Prediction & Interpolation
The client makes up for latency or packet loss by predicting the other player’s movement for the next frame. Once the correct information is received, the client smoothly interpolates towards the “correct” position. Allows to save bandwidth and control the amount of packets to be sent. -
Custom Packets of Data
The packets of information to be sent are custom structs that get filled with information before being converted into bytes that are streamed to the receiving sockets.
Behind the Scenes
Background
My goal for this project was to learn the fundamental principles of networking used in game development. To accomplish this, I used Unity since it was the game engine I was most comfortable with for setting up minimalistic gameplay.
The Process
Through this project, I gained a solid foundation in the basic principles of networking used in game development, such as packet structure, latency, and reliability. It also allowed me to expand my skills in Unity and C++, as well as working with .NET sockets.
For the server-side, I decided to use C++, the primary language taught for networking, and one that I was keen to practice. However, using Unity for the game meant I needed to use .NET sockets to establish communication between the client and server.
To test the effectiveness of my networking implementation, I used the Clumsy tool. This allowed me to simulate network lag, packet loss, and other network-related issues to identify areas that needed improvement.
Overall, this project was a valuable learning experience that provided me with a better understanding of the intricacies of networked games and the tools and techniques needed to develop robust, reliable systems.