DarkRift Networking 2 – Pro

by [email protected]

This is a paid asset, but now you can download DarkRift Networking 2 – Pro Free.

Detail this asset from Unity Store: Original Link

DarkRift Networking 2 – Pro v2.9.1 (Latest version)

Download Now

Fast, Flexible and Powerful networking for Unity. Rewritten from scratch to make it the best.

DarkRift takes a code-first approach to cloud based networking to make a super simple and super easy to learn networking solution that can be used for absolutely any type of game.

– No CCU limitations – No need to fork out for expensive licenses no matter how many users.
– Fully multithreaded – Make the most of vertical scaling and use your servers as efficiently as possibly.
– Unity or no Unity – Run your cloud servers from a Unity instance or run them standalone for a little extra performance.

The Pro version brings even more features to your game including our matchmaker, server clustering and server monitoring.

Unity Forum Thread
Community Discord
Documentation
Wiki

Getting Started
Welcome, and it’s nice to know you want to learn DarkRift! This tutorial aims to be a comprehensive guide for anyone who wants to get started with DarkRift no matter how much networking experience you have. Nevertheless, as someone who hates oversimplification, I’ll try and keep it interesting for people who do have networking experience!

If you want to learn DarkRift you’ll need a solid grasp of C# and a good knowledge of Unity. DarkRift also uses multithreading quite extensively so, although we won’t be using it in this tutorial, to get the most out of DarkRift you’ll need to understand multithreading very well!

As a tutorial, we’re going to recreate a popular game called Agar.io. We won’t implement all the features it has but we’ll get a basic system of moving and eating going and you can always add the others as an exercise afterwards.

Before we jump into the art of DarkRift we should explore how DarkRift operates.

Hopefully the autogenerated properties should be fairly self-explanatory. When implementing them remember:

Version should follow Semantic Versioning (unless you really hate best practices). It is used to trigger upgrades to plugins (we’ll cover that later) so you should give it a default value now.
ThreadSafe indicates whether your program can handle multithreaded events to boost performance. Since I won’t cover any multithreading in this set it to false, if you know about multithreading then it might be a nice exercise at the end to reimplement the plugin with multithreading enabled!

DarkRift uses plugins to implement all server side logic, you write plugins as you would develop a standard .NET library and then you just drop the generated DLL into DarkRift’s ‘Plugins’ directory. DarkRift offers a large API for managing clients and sending messages etc. and provides events that inform your plugins when a client connects, sends a message etc.

Everything related to the server code is in the namespace DarkRift.Server, everything to do with the client in DarkRift.Client and everything used in both is just in DarkRift.

Setting up the Plugin
Create a new Class Library C# project in Visual Studio named something like “AgarPlugin” and add references to DarkRift.Server.dll and DarkRift.dll.

WARNING
If you are using the Free version of DarkRift you will need to create a .NET Framework plugin, only the .NET Core build of the Pro version of DarkRift supports .NET Core/Standard plugins.
Rename the default class to AgarPlayerManager and rename the file similarly. Add using directives to the top of the file (using DarkRift; and using DarkRift.Server;) so that we have access to both DarkRift.Server and DarkRift namespaces.

All plugins in DarkRift must inherit from DarkRift.Server.Plugin so that DarkRift can correctly discover and instantiate them and so it can easily read details about your plugin. It is also your entry point into DarkRift’s API so that you make changes on the correct server instances.

Go ahead and make AgarPlayerManager inherit from Plugin, you’ll notice Visual Studio throws an error saying that there is no constructor so add it. You’ll then notice it says that it does not implement a number of abstract properties, once again add them. If you’re following along, you should have a class like this:

Related Posts

Leave a Comment