Skip to content

FenrirServer/Fenrir.Multiplayer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fenrir Multiplayer

Fenrir Multiplayer SDK

Tests Deploy

License Issues NuGet Unity Package Manager

Fenrir is a platform for building server-authoritative real-time multiplayer games with C# and .NET.

This library provides supports for building multiplayer games using Unity on the client-side and .NET and Docker on the server-side.

It is optimized for real-time multiplayer and provides fast reliable UDP layer and a basic serialization engine. It also supports various serialization engines and plug-ins.

Fenrir provides a great balance between performance and ease of development and makes it extremely quick to build multiplayer games of any genre.

Documentation

Table of Contents:

Quick Start

Installing Unity Package

This package can be installed using Unity Package from https://upm.fenrirserver.org registry.

Fenrir Multiplayer

  1. In Unity, open EditProject SettingsPackage Manager and add a Scoped Registry using URL: https://upm.fenrirserver.org
  2. Open WindowPackage Manager and switch to Packages: My Registries. Select Fenrir Multiplayer and click Install

Generating Server Project

Fenrir Multiplayer Unity Package comes with a server template that is recommended (but is not strictly required) to use.

To generate a server project, click WindowFenrirOpen Server Project.

Server Project

If a project server has never been generated, dialogue window will open asking to generate the package. Select Generate.

Generate Server Project

Editor script will generate and open a .NET Solution in the folder next to Assets:

📂MyGame
 ┣ 📂Assets
 ┣ 📂Packages
 ┣ 📂Library
 ┣ 📂ProjectSettings
 ┣ 📁Server                      ← Generated Server folder
   ┣ 📂 MyGame.Server            ← Server .NET Project 
   ┣ 📂 MyGame.Shared            ← Server and Client Shared Library
   ┣ 📄 ServerApplication.sln    ← Server solution file
   ┗ 📄 Dockerfile               ← Dockerfile that defines how the docker image for your server is built

Once the solution file is open, you can build and run the server.

Connecting to Server

Fenrir Multiplayer allows you to build server-authoritative multiplayer games with Unity and .NET.

Unlike most networking solutions for Unity, Fenrir allows (and encourages) to separate client and server logic. Data contracts and common code can be shared between client and server.

Example Server:

Note: Server template that comes with Unity Package includes basic hello world example for the server, which is also provided here.

using var networkServer = new NetworkServer() { BindPort = 27016 };
networkServer.Start();

Example Client:

using var networkClient = new NetworkClient();
var connectionResponse = await networkClient.Connect("http://localhost:27016");
if(connectionResponse.Success)
    Debug.Log("Connected!");
else
    Debug.Log("Failed to connect:" + connectionResponse.Reason);

Reference Project

Please check out TicTacToe repository for more examples!

Contributing

For problems with this library, please open a GitHub issue or a pull-request.

For issues with Fenrir Cloud, please contact customer support or your account manager.

License

Fenrir.Multiplayer is an open source software, licensed under the terms of MIT license. See LICENSE.txt for details.