Skip to content

Client Movement + Replicate Jitter #6

@Sjael

Description

@Sjael

When moving, rotating, and watching a number tick up over time (when a component is using the replicate plugin), there is a jitter on the client. Numbers wont increment smoothly, rotation and movement will take a few frames to 'settle'. I've isolated some of this issue to the rewind function

pub fn rewind<C>(
mut commands: Commands,
entities: &Entities,
tick: Res<NetworkTick>,
snapshots: Res<SnapshotBuffer<C>>,
) where
C: 'static + Component + Clone,
{
if let Some(snapshot) = snapshots.snapshots.get(&*tick) {
for (entity, component) in snapshot.0.iter() {
if entities.contains(*entity) {
commands.entity(*entity).insert(component.clone());
}
}
} else {
error!(
"no snapshot for component: {:?}",
std::any::type_name::<C>()
);
}
}

Commenting that function out fixes the number jitter, so I'm thinking a lot of it is in here, but the movement jitter only get's half fixed. Perhaps it is this function potentially setting the 'Owned' player's input back to the previous frame is the other part?

pub fn client_apply_input_buffer<I>(
tick: Res<NetworkTick>,
mut player_input: ResMut<I>,
input_buffer: Res<QueuedInputs<I>>,
) where
I: 'static
+ Send
+ Sync
+ Resource
+ Component
+ Clone
+ Default
+ Serialize
+ for<'de> Deserialize<'de>
+ Debug
+ Resource,
{
if let Some(input) = input_buffer.get(&*tick) {
//info!("{}: {:?}", tick.tick(), input);
*player_input = input.clone();
} else {
//error!("no input: {}", tick.tick());
}
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions