Currently going through the process of restructuring my game after realising client prediction is necessary. I’ve been informed that traditional unity physics is non deterministic. Which is leading me to the path of building my own physics component. But how do I ensure my own physics script calculations are deterministic? Should I be avoiding math library’s or do some custom rounding?
#Deterministic physics for Gameobjects
1 messages · Page 1 of 1 (latest)
I'm not computer scientist, but my understanding is that the issue is surrounding floating point operations. I'm sure Gaffer on Games has a article on determinism but here is a good one from the Box2D devs
https://box2d.org/posts/2024/08/determinism/
Determinism means many things when it comes to game development and especially physics engines. Generally in game development we like things to be repeatable. This makes debugging easier. This doesn’t rule out emergent behavior though because player input can be viewed as random.
Testing Determinism Determinism is a brittle feature. It is easy...
Do you know of any examples of client Prediction models? I want to know how other setups push there clients simulation ahead of the server, Currently im just forcing my client to step through 25 frames worth of physics & movement at the start to fast forward the simulation, but 25 frames ahead is too far ahead, id like my clients to consistently be 3-5 frames ahead of my server but this has proved more difficult than i originally thought it would
Using Ping doesn't seem great to use here as it seems to be somewhat inaccurate sometimes which can lead to my client falling behind again
You can look at how Netcode for Entities does it here
You can also look up GGPO or this c# port called Backdash
Prediction is less about being a fixed amount of frames ahead and is more about immediately simulating locally based on input and doing reconciliation later if needed.
I'm also not sure what else there is to use besides ping/latency.
Any idea how i can add some interpolation? Im still using unity physics RBs, and im using physics.simulate to run my client prediction, and its potentially workable, the discrepancy's arent too bad as its only running 4 ticks ahead therefore it cant go far off track, but i cant turn on interpolate since ive set the physics to script mode
in that video the boat is moving at 50FPS because its moving in fixed Update