Code Monkey home page Code Monkey logo

unitydots-thesis's Introduction

Contributors Forks Stargazers Issues MIT License
Unity C# Visual Studio

Multiplayer Applications and Games Project
on Unity DOTS Architecture

This project was carried out as an integral part of my bachelor's degree thesis in Computer Engineering, concerning the new Unity DOTS architecture. The goal of the paper, in addition to analyzing the new data-oriented layout provided by the ECS-based model, was to create a working multiplayer game prototype made entirely using DOTS.
Explore the docs »

View Demo · Thesis · Presentation · Report Bug | Request Feature · Italiano

Table of Contents

  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgements

About The Project

Data-Oriented Technology Stack (DOTS) is a set of libraries created by Unity over the last few years, which is still under development at the time of writing (2021).

DOTS proposes to replace the old architecture & programming pattern of the game engine, that was based on a component model (GameObject + MonoBehaviour), with a new one based on ECS (Entities, Components, Systems). The goal is to obtain an architecture that is not limited by the object-oriented programming, which is known to have several pifalls and problems - mainly related to polymorphism, inheritance chains and reference types.

In this regard, through a data-oriented layout, DOTS allows to obtain performance by default, as the code becomes organized through the separation between data (placed inside the components) and behaviour (confined inside systems). Runtime "things" are no longer heavy objects, with data scattered in memory, but simple numeric indexes representing entities, which we can compare to the keys of a database. Among the many advantages that come with this new architecture, what stand out is the possibility to make the most of modern CPUs, exploiting the potential of multiple cores and allowing efficient use of caches, which are not satured by the myriad of useless or unnecessary data present in objects. Moreover, thanks to the separation logic, the code that developers write becomes a good low-level approximation of an already correct and efficient solution, which therefore doesn't need, if not in rare cases, to be optimized.
The main packages used to make the prototype are:

The following animations show an example run of the prototype, with an headless server and two connected clients: one running in the Unity editor, the other as a standalone application on a different computer. With the NetCode package, when entering PlayMode inside the editor, Unity runs the server, a client and an arbitrary number of thin clients (in this demo we didn't make use of any of those).

EditorGIF StandaloneGIF
PC1: Unity Editor PC2: Standalone Build

Built With

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

  • Git
  • Unity Hub
  • Unity 2020.2.1 or higher

Installation

  1. Install Git at Download Git.
  2. Clone the repo.
    git clone https://github.com/mikyll/UnityDOTS-Thesis
  3. Download Unity Hub at Download Unity.
  4. Install a proper Unity version (2020.2.1 or higher) at Download Archive or from Unity Hub.
  5. Add the project directory on Unity Hub: Projects > Add > Select Directory.

Usage

To test the prototype in multiplayer you can create a build for a standalone client, then enter PlayMode in the editor and connect the standalone application; otherwise you can create one build for the server and one for the client and connect several clients to the server.

For more examples, please refer to the Documentation.

Roadmap

See the open issues for the full list of proposed features (and known issues).

Open Issues

  • The third person camera sometime starts flickering.
  • Physics simulations with dynamic entities are not synchronized between different clients.
  • Standalone builds sometime crash.

Future developments

  • Clients disconnection handle.
  • Main menu where and pre-match lobby.
  • Player scoreboard.
  • Inventory mechanic.

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project.
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature).
  3. Commit your Changes (git commit -m 'Add some AmazingFeature').
  4. Push to the Branch (git push origin feature/AmazingFeature).
  5. Open a Pull Request.

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Michele Righi - [email protected]

Project Link: github.com/mikyll/UnityDOTS-Thesis

Acknowledgements

LinkedIn GitHub followers

unitydots-thesis's People

Contributors

mikyll avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

unitydots-thesis's Issues

Unity Physics Collision System Using NetCode

There are two main issues:

  1. The collision system doesn't work properly between static entities and ghost entities if those are moved by updating Translation component. For this reason in PlayerMovementSystem.cs we had to update the PhysicsVelocity component of the PlayerCapsule, but the movement is obviously delayed, because it needs to accelerate from zero.
  2. Collision and Interactions between ghosts and dynamic object doesn't always work as expected (sometimes the ghost of the CapsulePlayer passes through the dynamic object, even though they should collide).

Jump Mechanic

We would like to add a perfectly working jump mechanic for the capsule.
Basically the jump is enabled by default, when the player jumps it gets disabled, and it returns enabled as soon as the player collides with the floor.
Probably UnityPhysicsSamples repository could be useful: there is a use case with a character controller, which should handle the jump too.

Permanent Change-Color Portal

File PermanentChangeMaterialOnTriggerSystem.cs

Currently the system uses the StatefulTriggerEvent buffer, even if it only check for the entity to enter, so we actually don't need the buffer state.
The purpose is to remove the usage of the buffer (in DynamicBufferTriggerEventAuthoring.cs), using just the simple TriggerEvent. This will solve the warning problem with memory leak in the newer version, which was thrown when we tried to use DynamicBufferTriggerEventAuthoring.cs.

Pre-Match Lobby

We would like to insert a lobby between the main menu and the game scene, where players can see each other and say when they're ready to start the match. When everyone is ready the game automatically starts (with a countdown timer?).

Kill&Respawn Trigger Box Below the Map

We want to insert a kill&respawn box below the map, that is triggered whenever a CapsulePlayer entity passes through it.
This should delete the entity and respawn it at the center of the map, as it happens when a client first connects.
A good starting point could be checking the PhysicsSamples repository, which contains many useful demos.

Camera Flickering

Probably File CameraFollowSystem.cs

Sometime the camera starts flickering. Actually not sure if the problem is the follow camera system, the movement system or another one.
However I think the problem is related to the system update order.

Capsule Heading Rotation System

We would like to introduce:

  1. A capsule steering system, which turns the heading of the capsule to the mouse pointer, using Unity Physics RayCasts.
  2. A camera option to toggle the visual between thrid and first person.

Player Scoreboard

A scoreboard showing the current score of all playing clients, activable with "TAB" command. There is already a score system which increments the player score when picking up a collectible, and a system that handles the scoreboard showing with TAB command.
Maybe this last one could be changed by updating the score on the server and handle the showing of the scoreboard on the client (without sending a command, which is quite useless).

Main Menu

A cool feature would be to insert a main menu before the scene loading, where players can set their nickname, choose a color and start the "matchmaking" with the click of a button.

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.