this post was submitted on 04 Feb 2025
15 points (100.0% liked)

Bevy

269 readers
4 users here now

A community for discussion around the bevy game engine! https://bevyengine.org/

founded 1 year ago
MODERATORS
 

It’s a crate for server-authoritative networking. We use it for Project Harmonia, but it's general-purpose.

Kinda our 30th anniversary πŸ˜… This release introduces remote triggers. The API is similar to our networked events. Here’s a quick showcase for client triggers:

app.add_client_trigger::<DummyEvent>(ChannelKind::Ordered)
    .add_observer(receive_events)
    .add_systems(Update, send_events.run_if(client_connected));

fn send_events(mut commands: Commands) {
    commands.client_trigger(DummyEvent);
}

fn receive_events(trigger: Trigger<FromClient<DummyEvent>>) {
    info!("received event {:?} from {:?}", trigger.event, trigger.client_id);
}

Server triggers have a similar API. Targeting entities is also supported.

We now also provide an example backend and examples that directly from the bevy_replicon repo. The examples have also been re-written to take advantage of the latest Bevy and Replicon features.

πŸ“œFull changelog πŸ“¦bevy_replicon

top 2 comments
sorted by: hot top controversial new old
[–] fil@programming.dev 2 points 2 weeks ago (1 children)

How are triggers different from events?

[–] Shatur@lemmy.ml 5 points 2 weeks ago

The difference is the same as between Bevy's regular triggers and events. We aim to mirror the Bevy API and simply make it networked.

Events are buffered and pull-style, while triggers are called on commands flush and can target entities and components. Triggers were introduced in Bevy 0.14. Generally, you should use triggers for events that happen rarely and events for things that need to be processed in batches.