Giter Club home page Giter Club logo

unet-controller's Introduction

A CharacterController based controller for use in Unity's new Networking system.

End-of-life

The (player movement part of the) project does not fully work with Unity 2018.2+ and is not fully programmed in data-oriented, entity component based design, which is the future of the engine. There will not be any feature improvements to the code, apart from occasional bug fixes caused by the engine updates. The code will stay as a basic logic of client-side predicted, server-side authoritative networking system. Forks are welcome.

Features
  • Client-side prediction.
  • Client-side reconciliation.
  • Interpolation.
  • Snapping to grid in order to suppress floating point nature.
  • Relatively low overhead.
  • Quake-like strafing. But most likely very incomparable.
  • Crouching.
  • Animations.
  • Network data analyzer to compare the results between the server and the client.
  • First person and third person camera.
  • Sliding of steep surfaces.
  • Ability to set AI target (basic, moves straight towards the target).
  • Recording and playing back gameplay.
  • Foot IK.
  • Ragdoll.
  • Lag compensation (WIP).
Performance (On 2015 MacBook Pro with quad-core i7)
  • Up to 1 millisecond on server every time a network update happens.
  • Up to 1 millisecond on client every time a network update happens. Sometimes it jumps a bit higher if there are a lot of inputs to replay during reconciliation. That is due to high latency.
  • Very small overhead on non local clients moving.
  • GC allocations 80 bytes per player. This is due to CharacterController.
  • Way higher GC allocations on the server side (and while recording gameplay for that matter), due to the need of storing history of the objects for lag compensation.
How does it run fast
  • It moves character only when network update occurs and then interpolate until the next network update in LateUpdate.
  • Efficiend data reusing with as least locals as possible (as they cause GC allocations).
Current issues
  • Update Once and Lerp mode does not work well with the update rates over 50hz. Use lower send rate or a higher one with Update Once mode.
TODO
  • Add jumping between updates so jumping would feel good even on small update periods.
  • Complete lag compensation.
  • Fix issues.

unet-controller's People

Contributors

h33p 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

Watchers

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

unet-controller's Issues

Vector3.zero Player spawn issue

Remote players spawns on Vector3.zero before moving to their correct positions, normally that happens automatically (It may take some time) but sometimes they're there until they press a key.

Flags.IS_GROUNDED is always set

I tried the demo of this controller, and the player can jump in the air forever. I tried looking into changing this behaviour, but found this in the code:

hitNormal = new Vector3(0, 0, 0);

if (Vector3.Angle(Vector3.up, hitNormal) <= data.slopeLimit)
    inpRes.flags |= Flags.IS_GROUNDED;
else
    inpRes.flags &= ~Flags.IS_GROUNDED;

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.