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

Float might cause desync over time. #5

Closed
FireBrandMint opened this issue Aug 23, 2021 · 9 comments
Closed

Float might cause desync over time. #5

FireBrandMint opened this issue Aug 23, 2021 · 9 comments

Comments

@FireBrandMint
Copy link
Contributor

FireBrandMint commented Aug 23, 2021

Floating points are very infamous for not being calculated properly and causing a lot of issues, including the possibility that they give different results on different machines.

The "solutions" i know (honestly they are pretty risky, there might be something else that's better):

  • Correct floats with some calculation related to scale. (might not solve the issue tbh, for example: the difference between the resulting move_and_collide or just changing the position could theoretically be more than the scale, causing a bigger desync than if it didn't have this calculation)

  • Make the server send the entire world state every X seconds and resimulate. (might be too much for UDP, and it might take a lot of work, but it's the safer option. If you try this let me know how i can help you, i'm very bad at this stuff but i can try)

@Carbone13
Copy link
Owner

Hey there, I suggest reading my last comment on your PR, it explains the situation well.
Also I'm working on a 100% deterministic physics. It still need more functionalities but once coupled with this repo, it could give good result.
About the second solution it can be something to implement, I mean if people don't want it they may just turn it off. The good point is that such logic is already implemented at the end of the sync manager, it's only comparing state and crying if they don't match and the send logic is not abstracted to the Network Adaptor, but that's not a big amount of work tbh 🙂

@FireBrandMint
Copy link
Contributor Author

Okay, now i read it.

@FireBrandMint
Copy link
Contributor Author

FireBrandMint commented Aug 23, 2021

Oh that's right, now i'm reading it, you're talking about RemotEstateMismatch, thank you for you patience,

@Carbone13
Copy link
Owner

Yes exactly, now the logic need to be determined, if we discover a mismatch we need a strong logic to determine which one is right

@FireBrandMint
Copy link
Contributor Author

FireBrandMint commented Aug 23, 2021

Maybe just say "if it's the client then your state is wrong and you must resimulate" then?

@Carbone13
Copy link
Owner

Carbone13 commented Aug 23, 2021

Yes but as this is 100% p2p their is no clear server, but well most of the game will implement a "group/game master" guy, so it should not be a problem 🙂

@Carbone13
Copy link
Owner

As long as everyone end up in the same state, that's all we want 😅

@FireBrandMint
Copy link
Contributor Author

Yeah, that sounds very good,

@FireBrandMint
Copy link
Contributor Author

FireBrandMint commented Aug 23, 2021

Just leaving this here, there's a problem with sending the world state: if the player changed input and the server sends them the state before the input gets rolled back without the input, that could cause a desync, the "strong logic" you talked about really matters.

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