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

Fix prediction/interpolation interaction with authority transfer #759

Merged
merged 1 commit into from
Jan 3, 2025

Conversation

cBournhonesque
Copy link
Owner

@cBournhonesque cBournhonesque commented Jan 3, 2025

Fixes #639

Prediction/Interpolation was not working correctly when combined with authority transfer.
An example use case is:

  • spawn E1 on client C1
  • transfer authority to server S, with prediction/interpolation enabled

How do we make sure that C1 will now spawn a predicted/interpolated entity?

This PR accomplishes this with several changes:

  • when the authority is transferred, the new authoritative peer (for example server S) will check if the old authority wants to have prediction/interpolation. If it's the case, we:
    • pass that information directly in the AuthorityChange message. (we cannot send a separate ShouldBePredicted component insert, because that message might arrive before the AuthorityChange message so it will be discarded by C1)
    • send a Spawn message, so that C1 has a receiver GroupChannel and can update the ConfirmedTick (needed for prediction/interpolation). (Another option would be to not have a Spawn message at all but to include the ReplicationGroup in the AuthorityChange message so that upon receipt C1 can create a GroupChannel.) We make sure that on the receiver side, if we receive a Spawn for an existing entity we still update the local_entity_to_group for the receiver channel
    • update the sender GroupChannel on S to have an updated send_tick so that we don't send redundant component updates to C1, we only send updates since the authority transfer started. (Fixes Think about how to replicate changes after authority-transfer #758)

This PR adds one important restriction:

  • if you transfer authority to a peer P, the peer P MUST have added the Replicate bundle before the authority transfer is done

@cBournhonesque cBournhonesque merged commit 2526956 into main Jan 3, 2025
1 of 4 checks passed
@cBournhonesque cBournhonesque mentioned this pull request Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant