High-level networking library that extends the bevy_replicon library to allow snapshot interpolation and client-side prediction

Overview

bevy_replicon_snap

A Snapshot Interpolation plugin for the networking solution bevy_replicon in the Bevy game engine.

This library is a very rough proof of concept and not meant to be used in productive games

Features

  • Basic but customizable snapshot interpolation for replicated components
  • Client-Side prediction:
    • Owner predicted: Owner client of the entity predicts, other clients interpolate

In the examples you can find a clone of the Simple Box example of bevy_replicon, in 3 versions: no interpolation or prediction, interpolated, predicted. I recommend to look at the diffs between those examples to gain a better understanding how this plugin works.

Usage

Setup

Add the bevy_replicon plugin and this plugin to your bevy application.

The plugin needs to know the maximum server tick rate to estimate time between snapshots so it needs to be passed in on initialization:

const MAX_TICK_RATE: u16 = 30;

...

.add_plugins((
    DefaultPlugins,
    ReplicationPlugins
        .build()
        .set(ServerPlugin::new(TickPolicy::MaxTickRate(MAX_TICK_RATE))),
    SnapshotInterpolationPlugin {
        max_tick_rate: MAX_TICK_RATE,
    },
))

...

Interpolation

To allow a Component to be interpolated it needs to implement the traits: Interpolate, SnapSerialize and SnapDeserialze.

Fortunately this library provides derive macros for those (Note: Note Interpolate macro only works for types that have a lerp() function right now)

use bevy_replicon_snap_macros::{Interpolate, SnapDeserialize, SnapSerialize};

#[derive(
    Component,
    Deserialize,
    Serialize,
    Interpolate,
    SnapSerialize,
    SnapDeserialize,
    Clone,
)]
struct PlayerPosition(Vec2);

You can also implement Interpolate manually to customize interpolation behaviour for any component.

Next you need to register the component for Interpolation:

app.replicate_interpolated::<PlayerPosition>()

this also registers the component for replication by bevy_replicon.

Last Step is to add the Interpolated Component to any entity that should be interpolated.

commands.spawn((
    PlayerPosition(Vec2::ZERO),
    Replication,
    Interpolated,
    ...
));

Client-Side Prediction

Coming soon.. In the meantime check the "predicted" example!

Alternatives

  • bevy_timewarp An awesome predict/rollback library that also has integration with bevy_replicon
You might also like...
Low-level Bitcoin P2P Network Client

Peerlink What is Peerlink? Peerlink is a low-level network client for the Bitcoin P2P network written in Rust. It uses a nonblocking reactor to accept

Nym provides strong network-level privacy against sophisticated end-to-end attackers, and anonymous transactions using blinded, re-randomizable, decentralized credentials.

The Nym Privacy Platform The platform is composed of multiple Rust crates. Top-level executable binary crates include: nym-mixnode - shuffles Sphinx p

Outp0st is an open-source UI tool to enable next-level team collaboration on dApp development over Terra blockchain
Outp0st is an open-source UI tool to enable next-level team collaboration on dApp development over Terra blockchain

Outp0st is an open-source UI tool to enable next-level team collaboration on dApp development over Terra blockchain

A low-level assembly language for the Ethereum Virtual Machine built in blazing-fast pure rust.
A low-level assembly language for the Ethereum Virtual Machine built in blazing-fast pure rust.

huff-rs • huff-rs is a Huff compiler built in rust. What is a Huff? Huff is a low-level programming language designed for developing highly optimized

An EVM low-level language that gives full control over the control flow of the smart contract.

Meplang - An EVM low-level language Meplang is a low-level programming language that produces EVM bytecode. It is designed for developers who need ful

MLIR Rust multi-level compiler framework

MLIR-RS Multi-Level Intermediate Representation framework for Rust. What Modern programming language design is moving towards multi-level lowering to

An open source Rust high performance cryptocurrency trading API with support for multiple exchanges and language wrappers. written in rust(🦀) with ❤️

Les.rs - Rust Cryptocurrency Exchange Library An open source Rust high performance cryptocurrency trading API with support for multiple exchanges and

A high performance blockchain kernel for enterprise users.
A high performance blockchain kernel for enterprise users.

English | 简体中文 What is CITA CITA is a fast and scalable blockchain kernel for enterprises. CITA supports both native contract and EVM contract, by whi

An extremely high performance matching engine written in Rust.

Galois Introduction Galois is an extremely high performance matching engine written in Rust, typically used for the crypto currency exchange service.

Owner
Ben
Ben
⚡️ NFT Snapshot script written in Rust for blazingly fast speeds ⚡️

⚡️ NFT SNAPSHOT ⚡️ This project uses rust's blazingly fast performance along with the ethers-rs library to read blockchain state. Setup You will have

Trevor Johnson 4 Oct 14, 2022
Snapshot testing tool for Nix based on haumea [maintainer=@figsoda]

namaka Snapshot testing tool for Nix based on haumea nix shell github:nix-community/namaka namaka check # run checks namaka review # review pending sn

Nix community projects 30 Apr 17, 2023
Koofr Vault is an open-source, client-side encrypted folder for your Koofr cloud storage offering an extra layer of security for your most sensitive files.

Koofr Vault https://vault.koofr.net Koofr Vault is an open-source, client-side encrypted folder for your Koofr cloud storage offering an extra layer o

Koofr 12 Dec 30, 2022
Draw routes in MapLibre snapped to a street network using client-side routing

MapLibre route snapper This plugin lets you draw routes in MapLibre GL that snap to some network (streets, usually). Unlike similar plugins that send

Dustin Carlino 32 Jan 17, 2023
Rust DDC/CI high level library

ddc-enhanced-rs ddc-enhanced-rs is a cross platform Rust crate and Node package for controlling monitors with DDC/CI. Documentation Rust: https://docs

ThalusA 5 Oct 2, 2022
Tiny CLI for submitting large calldata transactions to EVM networks to stress test the networking layer. Main motivation: EIP4844blobs.

stress4844 Tiny CLI for submitting large calldata transactions to EVM networks to stress test the networking layer. Main motivation: EIP4844 blobs. ca

Paradigm 50 Jan 4, 2023
Tiny CLI for submitting large calldata transactions to EVM networks to stress test the networking layer

Tiny CLI for submitting large calldata transactions to EVM networks to stress test the networking layer. Main motivation: EIP4844blobs.

Paradigm 50 Jan 4, 2023
Authenticated Encryption with Associated Data Algorithms: high-level encryption ciphers

RustCrypto: Authenticated Encryption with Associated Data (AEAD) Algorithms Collection of Authenticated Encryption with Associated Data (AEAD) algorit

Rust Crypto 457 Jan 4, 2023
Extremely low-latency chain data to Stackers, with a dose of mild humour on the side

Ronin Hello there! Ronin is a ultra-speed Stacks API server. It's super lightweight, but scales easily. Why are we making this? Because we don't like

Syvita Guild 11 Mar 29, 2022
🦀 Hop server side SDK for Rust

hop-rs (wip) Hop's Rust library. Requires Rust 1.61+ Installation [dependencies] hop = "0.0.0" Usage Create a project token or personal access token.

Tom 17 Jan 31, 2023