Skip to content

grazianobolla/godot-monke-net

Repository files navigation

🐒 Monke-Net

Static Badge GitHub License

C# Godot Addon that facilitates creating robust multiplayer games using the Client-Authoritative Server architecture, including client side prediction, entity interpolation, lag compensation and more!


Warning

MonkeNet uses its own fork of Godot-Jolt for networked physics, in this repository I've only provided the binaries for Windows, if you are on Mac/Linux you will have to compile Jolt yourself (it's a simple process)

📚 Background

After many years since my first attempt at making a functional multiplayer game, I came to one conclusion: developing multiplayer games is hard, specially when leaving the P2P architecture and opting for a more "competitive" approach like having an authoritative server. This project aims to provide a starting point that can be used to speed up the time it takes to go from idea to reality, utilizing its features like:

  • CharacterBody Client Side Prediction and Reconciliation
  • Snapshot Interpolation for smooth visuals
  • Clock Synchronization between the server and clients
  • State Replication between clients
  • Delta Compression for inputs/entity states
  • Lag Compensation for client to client interactions

Important

Keep in mind my approach was completely personal, as I don't have prior experience with any other networking solutions for game engines like Fishnet/Fusion/UnrealEngine etc, I wrote what was useful for me and that might not be the best approach, if you have any thought/opinion about how the addon does stuff please let me know.

🧩 Dependencies and .NET environment

MonkeNet requires your game project to use .NET 8, also it heavily uses ImGui to display very important debug information, this means you will also have to install ImGui Godot in your project, that's MonkeNet only dependency, altough I plan to remove it/make it modular in the future.

💾 Installation

MonkeNet is a Godot addon, to start using it copy the addons\monke-net\ folder, paste it into your project addons\ folder, and enable the plugin in your project settings. After this, you will have access to all MonkeNet resources.

📦 This Repository (Demo Project)

This repository is the developing environment for the addon, including tests and a demo project showcasing MonkeNet capabilities. If you have any trouble getting it to work, cloning this repository might be a good starting point that you can later adapt to your games requirements.

2024-12-15.01-11-03.mp4
Example recorded with 200ms lag, 5% packet loss, 10% out of order, 10% duplicated, 10% throttle in Clumsy 0.3

📐 Project Structure (WIP)

MonkeNet is structured in different "components" that are Nodes inside the Godot engine, these components work together to provide different functionalities. Usually for the same funcionality there is a Client component and a Server component altough they do different things. Here there are some examples:

  • ClientEntityManager.cs handles requesting an entity on the server while ServerEntityManager.cs actually takes that request and spawns the entity.
  • ClientNetworkClock.cs receives clock data from the server and updates its internal state, while the ServerNetworkClock.cs just runs a simple clock that increments each tick.

🐵 MonkeNet Singleton

The MonkeNetManager class is a singleton that can be used anywhere in your project and allows you to start either a server or a client.

🖥️ Client Side Components

  • Client Manager
  • Entity Manager
  • Network Clock
  • Snapshot Interpolator
  • Snapshot Rollbacker
  • Input Manager

🖧 Server Side Components

  • Server Manager
  • Entity Manager
  • Network Clock
  • Input Receiver

🤝 Shared Components

  • Message Serializer
  • Entity Spawner
  • Network Manager
  • MonkeNet Config

If you have any questions, please contact me on Discord, I'll be happy to help.