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::*;
use bevy_replicon::prelude::*;
use bevy_replicon_renet::RepliconRenetPlugins;
let mut app = App::new();
app.add_plugins((MinimalPlugins, 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 events.
§Replicon conditions
The crate updates the running state of RepliconServer
and connection state of RepliconClient
based on the states of RenetServer
and RenetClient
in PreUpdate
.
This means that Replicon conditions won’t work in schedules
like Startup
. As a workaround, you can directly check if renet’s resources are present. This may be resolved
in the future once we have observers for resources
to immediately react to changes.
Re-exports§
pub use bevy_renet::renet;
Modules§
Structs§
- Replicon
Renet Client Plugin client
- Adds renet as client messaging backend.
- Replicon
Renet Plugins - Plugin group for all Replicon renet backend plugins.
- Replicon
Renet Server Plugin server
- Adds renet as server messaging backend.
Traits§
- Renet
Channels Ext - External trait for
RepliconChannels
to provide convenient conversion into renet channel configs.