Non physics determinism of floating point math across platforms
Are operations on Vector2/3 / floats in unity deterministic? I am very familiar with IEEE-754 and how floating point integers work under the hood.. but am curious how Unity conforms to the specification or if it does any magic under the hood for determinism. Would I be forced to use fixed point arithmetic to achieve this?
Context: I am making a game where a simulation will be run based on some initial state and input added across the simulation. I will only use physics in the rendering pipeline for effects and other visuals. Users will play offline / async and the game servers will validate users past simulations by sending initial state + input + end state. It is paramount that on IOS, Android or Linux that the game code all produces identical results across runs so I can differentiate possible cheaters/hackers from innocent users and bugs. As well as minimize the amount of simulations the user does that get invalidated.. this would cause a cascade effect to ruin most of there efforts since the last verification.
The only thing I ever heard wasn't deter$$anonymous$$istic was physics system. That doesn't rule out other subsystems, but I haven't heard of any issues. You may want to sink some time into figuring out ti$$anonymous$$g as Unitys usual update functions run on variable time steps. For fixed time calculations, FixedUpdate may be a better choice, and then you can interpolate graphics based on the fixed simulation steps.
As for telling you if they use IEEE-754 or not on all systems, I can't tell :)
Answer by zty · Nov 25, 2015 at 02:49 AM
I'm also wondering the same. By using FixedUpdate, you can guarantee that on the same machine, same input and initial state will produce the same simulation. But what if on different architectures? Validating game play on the server is pretty common nowadays for mobile game for anti-cheat.
If you wonder, then don't answer the question with "I wonder this too!"
Please.
If no one can give a concrete and verifiable answer to your question, contact sales or support and tell them that not knowing the fp standard is a deal breaker and find another engine.
Or if that is unfruitful, consider rolling out your own tests across all systems you use to catch unexpected behavior to verify behavior yourself. Obviously ideally you shouldn't have to test the system you'll be using.