Pinecone Networking

Pinecone is a lightweight Networking library for Unity made by Benjamin Nilsson. It is designed for Unity 2021 LTS and is made to help small solo developers or teams to easily create multiplayer projects.

A more detailed blog post is coming soon...

Demo Video


How it Started

As part of my degree, I had to choose an artefact to create as part of my final year project. I had gained an interest from networking architectures from a previous module so I decided that I wanted to explore the world of multiplayer games. The idea was design and implement a generic and re-useable network library for the Unity game engine that eases the process of creating online-based games.


Architecture

Pinecone is set up with the Server & Client in one project in order to speed up the development process and productivity. It is inspired from other networking libraries seen commonly around the Unity community such as Mirror or Photon; This is to help users easily get started or allow the ability to migrate from other existing libraries without having to re-start the learning process.

Using C# source generators, Pinecone will automatically generate code once the user has specified a specific attribute. This generates a new function that is used hide all networking layers. Users simply have to call the generated function where afterwards, Pinecone will deal with the rest.

Pinecone comes with a built-in Transport layer that is created using TCP. It can by default sync Unity transforms and animators over a network. The attributes that Pinecone generates allow for easy custom behaviour without having to touch the networking back-end.

Attributes

Pinecone uses C# attributes and code generation to easily allow users to run client or server specific code such as Remote Procedure Calls (RPC). Below is a list of attributes and an example code snippet.

  • [NetworkRPC]

    Call the generated version of this from the server to tell all clients to run this method.
  • [NetworkTargetRPC]

    Call the generated version of this from the server to tell a specific client to run this method.
  • [NetworkCommand]

    Call this from a client to run this function on the server. Should not be called on the server.
  • [NetworkSync]

    Put this on a variable to sync it across the network. The variable must be changed on the server only.

  • Code Snippet

    
    public partial class Player : NetworkBehaviour
    {
        public void ServerPlayerExploded()
        {
            Generated.RpcExplode(this);
        }
    
        [NetworkRPC]
        public void RpcExplode()
        {
            Debug.Log("Player Exploded");
        }
    }
    
    

Tools Used

  • Unity 2021 LTS
  • Visual Studio 2022

Contact

Want to get in contact with me?

Email: benjaminnilsson1997@gmail.com

You can also contact me through
social media if preferred.