Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client Movement + Replicate Jitter #6

Open
Sjael opened this issue Dec 9, 2022 · 0 comments
Open

Client Movement + Replicate Jitter #6

Sjael opened this issue Dec 9, 2022 · 0 comments
Assignees

Comments

@Sjael
Copy link
Contributor

Sjael commented Dec 9, 2022

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());
}
}

@Aceeri Aceeri self-assigned this Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants