Expand description
Provides integration for bevy_replicon for bevy_renet.
§Getting started
This guide assumes that you have already read the quick start guide
for bevy_replicon.
§Modules
Renet API is re-exported from this drate under renet module. Features from bevy_renet are exposed via
renet_* features, which also re-export the corresponding transport modules. Like in bevy_renet, the netcode
transport is enabled by default.
So you don’t need to include bevy_renet or renet in your Cargo.toml.
§Plugins
Add RepliconRenetPlugins along with RepliconPlugins:
use bevy::{prelude::*, state::app::StatesPlugin};
use bevy_replicon::prelude::*;
use bevy_replicon_renet::RepliconRenetPlugins;
let mut app = App::new();
app.add_plugins((MinimalPlugins, StatesPlugin, RepliconPlugins, RepliconRenetPlugins));Similar to Replicon, we provide client and server features. These automatically enable the corresponding
features in bevy_replicon.
The plugins in RepliconRenetPlugins automatically include the Renet plugins, so you don’t need to add
them manually. If the renet_transport feature is enabled, the netcode plugins will also be added automatically.
§Server and client creation
Just like with regular bevy_renet, you need to create the
RenetClient and NetcodeClientTransport or
RenetServer and NetcodeServerTransport
resources from Renet.
For steam transport you need to activate the corresponding feature and use its transport resource instead.
This crate will automatically manage their integration with Replion.
Never insert client and server resources in the same app, it will cause a replication loop. See the Replicon’s quick start guide for more details.
The only Replicon-specific part is channels. You need to get them from the RepliconChannels resource.
This crate provides the RenetChannelsExt extension trait to conveniently create Renet channels from it:
use bevy::prelude::*;
use bevy_replicon::prelude::*;
use bevy_replicon_renet::{renet::ConnectionConfig, RenetChannelsExt};
fn init(channels: Res<RepliconChannels>) {
let connection_config = ConnectionConfig {
server_channels_config: channels.server_configs(),
client_channels_config: channels.client_configs(),
..Default::default()
};
// Use this config for `RenetServer` or `RenetClient`
}For a full example of how to initialize a server or client see examples in the repository.
Channels need to be obtained only after registering all replication components and remote messages/events.
§Replicon states
The crate updates the ServerState and ClientState based on the states of RenetServer
and RenetClient in PreUpdate.
This means that states won’t be updated in schedules like Startup.
As a workaround, you can directly check if Renet’s resources are present.
Re-exports§
pub use bevy_renet::renet;
Modules§
Structs§
- Replicon
Renet Client Plugin client - Adds Renet as the client messaging backend.
- Replicon
Renet Plugins - Plugin group for all Replicon renet backend plugins.
- Replicon
Renet Server Plugin server - Adds Renet as the server messaging backend.
Traits§
- Renet
Channels Ext - External trait for
RepliconChannelsto provide convenient conversion into renet channel configs.