lucaspoffo / renet

Server/Client network library for multiplayer games with authentication and connection management made with Rust
Apache License 2.0
620 stars 65 forks source link

Server sends only one message every ScheduleRunner tick #146

Open VisualEhrmanntraut opened 4 months ago

VisualEhrmanntraut commented 4 months ago

Is this a bug or am I doing something wrong? I'm making a headless server.

lucaspoffo commented 4 months ago

Without code it's hard to know the problem, you might be doing something wrong because it should send more messages. Are you using the example code as base? You can check the bevy_demo also

VisualEhrmanntraut commented 4 months ago

@lucaspoffo I cross-referenced the bevy and chat examples to get started with using this crate.

let transport = NetcodeServerTransport::new(server_config, socket).unwrap();
App::new()
    .add_plugins((
        MinimalPlugins.set(ScheduleRunnerPlugin::run_loop(Duration::from_secs_f64(
            1.0 / 120.0,
        ))),
        LogPlugin::default(),
        RenetServerPlugin,
        NetcodeServerPlugin,
        AssetPlugin::default(),
        PhysicsPlugins::default(),
        WorldPlugin,
    ))
    .insert_resource(server)
    .insert_resource(transport)
    .add_systems(Update, handle_events)
    .run();

The app is created as in the above snippet. Messages are transported later, in an Update system, which has a for loop that sends a bunch of messages on every iteration. Every tick of the schedule runner, the bevy crate sends only one message, instead of as many as possible, which is not what I expected. Do note that I am new at game development, so there might be something I'm doing that's not common practice, or something.