Expand description
Bevy adapter for the naia client.
Integrates naia’s entity replication and messaging into a Bevy application.
Server-replicated entities appear in the Bevy world automatically; client-
authoritative entities can be spawned and published via CommandsExt.
Runs natively (UDP) and in the browser (wasm32-unknown-unknown + WebRTC).
§Single-client apps (most common)
Use DefaultPlugin and DefaultClientTag — no phantom type needed:
fn main() {
App::new()
// .add_plugins(DefaultPlugins)
.add_plugins(DefaultPlugin::new(client_config(), protocol()))
// .add_systems(Startup, init) // call Client::connect here
.run();
}
fn my_system(mut client: Client<DefaultClientTag>) {
// use client here
}§Multi-client apps
Disambiguate each server connection with a distinct phantom tag type:
struct LobbyTag;
struct GameTag;
fn main() {
App::new()
.add_plugins(Plugin::<LobbyTag>::new(lobby_config(), protocol()))
.add_plugins(Plugin::<GameTag>::new(game_config(), protocol()))
.run();
}
fn lobby_system(mut lobby: Client<LobbyTag>) { /* ... */ }
fn game_system(mut game: Client<GameTag>) { /* ... */ }§Key types
| Type | Purpose |
|---|---|
DefaultPlugin | Single-client plugin (alias for Plugin<DefaultClientTag>) |
Plugin | Generic plugin for multi-client apps |
Client | Bevy-wrapped client SystemParam |
DefaultClientTag | Phantom type for single-client apps |
CommandsExt | Extension methods on Commands for replication |
ClientCommandsExt | Client-only extension methods on Commands |
events | Bevy events mirroring naia world events |
Modules§
- default_
channels - Built-in default channel definitions (DefaultUnreliable, DefaultReliable, etc.).
- events
- transport
- Transport-layer socket abstractions (UDP, WebRTC, local in-process).
Structs§
- Client
- Client
Config - Contains Config properties which will be used by a Server or Client
- Client
Wrapper - Command
History - Ring buffer of (tick, command) pairs for client-prediction rollback; old entries are pruned when the server acknowledges a tick.
- Default
Client Tag - Phantom tag type for single-client Bevy apps.
- Game
Instant - Server-relative millisecond timestamp that wraps at 2^22 ms (~70 minutes).
- Handle
Tick Events - Handle
World Events - Instant
- Represents a specific moment in time
- Plugin
- Bevy plugin that wires naia’s client replication into a Bevy
App. - Random
- Container for cross-platform Random methods
- Response
Receive Key - Typed token held by the receiver to identify which request a response answers.
- Response
Send Key - Typed token held by the sender to identify a pending request when its response arrives.
- Server
Owned - Timer
- A Timer with a given duration after which it will enter into a “Ringing” state. The Timer can be reset at an given time, or manually set to start “Ringing” again.
- World
Update
Enums§
- Entity
Auth Status - Authority lifecycle state for a delegated entity as observed by one endpoint.
- Jitter
Buffer Type - Configuration type for jitter buffer behavior
- Naia
Client Error - Errors that can be returned by the naia client.
- Publicity
- Publication visibility of an entity — the shared axis used on both sides of the connection.
Traits§
- AppRegister
Component Events - Client
Commands Ext - Extension methods on
Commandsfor client-side replicated resource authority management. - Commands
Ext - Extension methods on
EntityCommandsfor client-side replication and authority management. - Message
- Core trait for all naia message types — provides serialization, kind lookup, and entity-relation hooks.
- Replicate
- A struct that implements Replicate is a Component, or otherwise, a container of Properties that can be scoped, tracked, and synced, with a remote host
- Replicate
Bundle
Functions§
- sequence_
greater_ than - Returns whether or not a wrapping number is greater than another sequence_greater_than(2,1) will return true sequence_greater_than(1,2) will return false sequence_greater_than(1,1) will return false
- sequence_
less_ than - Returns whether or not a wrapping number is greater than another sequence_less_than(1,2) will return true sequence_less_than(2,1) will return false sequence_less_than(1,1) will return false
- wrapping_
diff - Retrieves the wrapping difference between 2 u16 values wrapping_diff(1,2) will return 1 wrapping_diff(2,1) will return -1 wrapping_diff(65535,0) will return 1 wrapping_diff(0,65535) will return -1
Type Aliases§
- Client
Owned - Default
Plugin - Alias for
Plugin<DefaultClientTag>— for single-client apps. - Tick
- Server-side tick counter, wrapping at
u16::MAX.