lightyear_frame_interpolation 0.22.4

IO primitives for the lightyear networking library
Documentation

This module is not related to the interpolating between server updates. Instead, it is responsible for interpolating between FixedUpdate ticks during the Update state.

Usually, the simulation is run during the FixedUpdate schedule so that it doesn't depend on frame rate. This can cause some visual inconsistencies (jitter) because the frames (Update schedule) don't correspond exactly to the FixedUpdate schedule: there can be frames with several fixed-update ticks, and some frames with no fixed-update ticks.

To solve this, we will visually display the state of the game with 1 tick of delay For example if on the Update state we have an overstep of 0.7 and the current tick is 10, we will display the state of the game interpolated at 0.7 between tick 9 and tick 10.

Another way to solve this would to run an extra 'partial' simulation step with 0.7 dt and use this for the visual state.

To enable FrameInterpolation:

  • you will have to register an interpolation function for the component in the protocol
  • FrameInterpolation is not enabled by default, you have to add the plugin manually
  • To enable VisualInterpolation on a given entity, you need to add the FrameInterpolate component to it manually
# use lightyear_frame_interpolation::prelude::*;
# use bevy_app::App;
# use bevy_ecs::prelude::*;

# #[derive(Component, PartialEq, Clone, Debug)]
# struct Component1;

let mut app = App::new();
app.add_plugins(FrameInterpolationPlugin::<Component1>::default());

fn spawn_entity(mut commands: Commands) {
    commands.spawn(FrameInterpolate::<Component1>::default());
}