Code Monkey home page Code Monkey logo

unitylockstep's Introduction

UnityLockstep

Discord

Currently the rollback of adding and changing entities should be stable. If you spawn or navigate entities in multiple game-instances, all simulations will end up in a synced state, no matter how many packets drop or how high the lag is. Clientside prediction makes sure that local commands are executed under any condition.

Video

Architecture

Overview

Server UI

ServerUI

Getting started

  1. Open Server.LiteNetLib/Server.LiteNetLib.sln
  2. Run Server-project (Console), enter "1" when asked for room-size
  3. Open SampleScene in Unity
  4. Hit play and wait until connection to server is established
  5. Holding right mouse button will continously spawn new agents, press 'X' to navigate all agents to your current mouse position

Getting started (multiplayer)

  1. Build and run the Unityproject
  2. Start the server. The roomsize will default to 2 after a few seconds of no input
  3. Hit play in Unity so you should now have two instances of the game running
  4. Wait until both players are connected to the server. The server will display a message when the simulation has started.
  5. For controls, same as above

Work in progress (ordered by priority)

  1. Synchronizing framerate. If a client lags too much or lag compensation is too low, the delayed input will force every other client to constantly rollback the simulation. The project requires a solution to minimize the need of rollback for every client.
  2. Performance spikes are currently by design. In case of an input from the very past, a rollback of many (speak: thousands of) ticks at once occur. Adding constraints like max. input-offset and adjusting framerates for slow clients will help improving everyones performance. The target-frame for rollback is also not optimized, this can save lots of performance too.
  3. Rollback for despawned (e.g. killed) entities is not implemented yet, it will arrive after navigation, combat/projectiles and health is working.

Dependencies

  • The ECS-Project currently targets .NET Framework 4.6.1 (#806)
  • The server targets .NET Core Framework 2.2.103 (link to setup)

References

Inspired by LockstepFramework, in memory of SnpM: https://github.com/SnpM/LockstepFramework

Uses a fork of BEPUPhysics for deterministic physics: https://github.com/sam-vdp/bepuphysics1int

Uses FixedMath.Net for deterministic fp-calculations: https://github.com/asik/FixedMath.Net

Uses Entitas as ECS Framework: https://github.com/sschmid/Entitas-CSharp

The project includes an implementation example using LiteNetLib: https://github.com/RevenantX/LiteNetLib

Initial commit was targeting the following protocol: https://www.reddit.com/r/Unity3D/comments/aewepu/rts_networking_simulate_on_serverbeat/. The project has shifted to an architecture you see above.

Limitations

  • Physics values are limited to 1000 so keep your world in these limitations or shift the world when your values become too large

unitylockstep's People

Contributors

gsphb avatar proepkes 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  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  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  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

unitylockstep's Issues

Operating efficiency is extremely poor

Hi
I ran with my computer and found that it was inefficient and often crashed, and it was also hard to run, so it looked bad. My computer configuration is quite high.

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.