ErnWong / crystalorb

Network-agnostic, high-level game networking library for client-side prediction and server reconciliation (unconditional rollback).
https://ernestwong.nz/crystalorb/demo
Other
220 stars 13 forks source link
client-side-prediction crystalorb game-networking rollback-netcode rollback-networking
WARNING: This crate currently depends on nightly rust unstable and incomplete features.

crystalorb

Network-agnostic, high-level game networking library
for client-side prediction and server reconciliation.

crates.io docs.rs ci cd Coverage



Quick start

You may copy the standalone example to use as a starting template, and build off from there. You may also want to check out crystalorb-mock-network and crystalorb-bevy-networking-turbulence, either to use directly in your projects, or as examples for you to integrate your own choice of networking layer.

If you prefer a more visual and interactive example, there is the demo shown above that uses the Rapier physics engine. Feel free to use the demo's source code as a starting template for your next project.

For more information about how to implement the required traits, refer to the docs.

About

Game networking is hard, because we usually want to give the illusion that the physics simulation is responsive, fair, and consistent between multiple game clients despite having significant network latency between the clients and the server. There are many different ways to solve the game networking problem. CrystalOrb tries implementing one of such ways.

CrystalOrb is a young networking library that implements:

CrystalOrb does not (yet) implement "lag compensation" (depending on your definition of "lag compensation"), because CrystalOrb clients currently simulate all entities (including other players) in the present anyway. Some netcode clients would rather simulate entities in the past except for the local player. There are pros and cons to both methods:

Caveat: You need to bring your own physics engine and "mid-level" networking layer. CrystalOrb is only a "sequencer" of some sort, a library that encapsulates the high-level algorithm for synchronizing multiplayer physics games. CrystalOrb is physics-engine agnostic and networking agnostic (as long as you can implement the requested traits).

Is CrystalOrb any good?

Doubt it. This is my first time doing game networking, so expect it to be all glitter and no actual gold. For more information on game networking, you might have better luck checking out the following:

(Yes, those were where I absorbed most of my small game-networking knowledge from. Yes, their designs are probably much better than CrystalOrb)

Similar and related projects

CrystalOrb is a client-server rollback library, and there are other kinds of rollback/networking libraries out there you should check out! Here are some other rollback libraries by other authors in the rust community you might be interested in:

Your project's not listed? Feel free to make a PR or submit an issue, and I'd be happy to promote it.

More examples

Your project's not listed? Feel free to make a PR or submit an issue, and I'd be happy to promote it.

Unstable Rust Features

CrystalOrb currently uses the following unstable features:

#![feature(const_fn_floating_point_arithmetic)]
#![feature(map_first_last)]
#![feature(adt_const_params)]
#![feature(generic_associated_types)]