Code Monkey home page Code Monkey logo

unitynetworkingapi's Introduction

Unity Version Twitter

Unity Networking API

The repository contains a solution for networking in Unity, it's made in pure C# without the usage of Unity's built-in HLAPI components. Please consider that this is a project made for learning purposes, so there are limitations, bugs and a lot of room for further improvements and tests, feel free to mail me with suggestions about the architecture or anything else.

Objetives

The main goal is to have two unitypackages, client and server, whitch will be starting points for future multiplayer prototypes. And also learn the basics of networking.

Projects

Here are the code of both projects:

  1. The Client Project.
  2. The Server Project.

Here is the link to both Unity Packages.

How to use it? And Demo Apps

Inside each package there are demo applications made to help with understanding the tool.

Currently in the demo you can:

  1. Instantiate players;
  2. Move players around and jump;
  3. Send text messages Client <-> Server;

Note: all the messages are processed in the server side.

Here is an image of two demo players connected to the server:

Here are the content of the demo scenes:

Creating the Server Application

The easiest way to create a server app is described below:

  1. Download the Server UnityPackage and import it into your game server. Link here.
  2. Create a new script and open it.
  3. Add the following import on top: using UnityGameServer;
  4. Change the parent class of the script to: BaseServerApplication
  5. Drop the script into a gameObject inside the scene.
  6. Drag and drop the scriptable object that contains the server configurations. The asset is located at: UnityNetworkingAPI/UnityGameServer/Assets/UnityGameServer/ServerConfigs.asset

It should look like this picture from the DemoServerApp.cs :

  1. Press Play and you should be able to see the following start up logs, which means the server is online in your local machine:

Creating the Client Application

The client application has almost the same set of steps as the server:

  1. Download the Client UnityPackage and import it into your game client. Link here.
  2. Create a new script and open it.
  3. Add the following import on top: using UnityGameClient;
  4. Change the parent class of the script to: BaseNetworkApplication
  5. Drop the script into a gameObject inside the scene.
  6. Drag and drop the scriptable object that contains the client configurations. The asset is located at: UnityNetworkingAPI/UnityGameClient/Assets/UnityGameClient/ClientConfigs.asset

It should look like this picture from the DemoClientApp.cs :

  1. Press Play and, if the server is online in your local machine, you should be able to see the following start up logs:

After both applications are connected a player will be instantiated and you will be able to move and using the keyboard WASD and Space.

Feel free to use the tool as you need :)

References

I used Tom Weiland tutorial series as a base to start my work. Check out his videos to have complementary explanations about networking.

unitynetworkingapi's People

Contributors

ycarowr avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

elkozirro

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.