So I have a barebones car prefab. It’s literally a box and 4 wheel colliders all around. When I run the car with the exact same inputs on my server and client, both cars end up in different positions.
Then I created two entirely new projects, dropped the same exact car prefab into it, and the positions were exactly the same. Again and again and again every time I ran the simulation.
I’ve checked the prefab 10 times over, they’re exactly the same. I’ve also checked the physics settings on all of my projects. Exactly the same. Physics timestep is also the same.
This is driving me absolutely insane, and I’ll appreciate any help.
Edit: The cars even spawn in at the wrong positions. I’ve set them all to spawn at a set position. The server car’s X position value after spawning (after the rigidbody has settled) is 0.0001383207 and both of the new simulation positions are 0.0001381642. The new simulations are exactly the same but the server values are extremely off. It is literally the same exact scene with just the car. This is so annoying.
I’ve also faced this same problem in the past and found no way to reproduce the exact behavior of the car using the inputs alone. PhysX is not deterministic. You may get somewhat similar behavior in the first 2-5 seconds, but then the results will quickly diverge in different directions each time.
The only way I found to replay the exact car behavior is to record not only the input, but also the position and rotation of the rigidbody (Rigidbody.position and Rigidbody.rotation) every FixedUpdate(). Then make the rigidbody kinematic and use Rigidbody.MovePosition and Rigidbody.MoveRotation from FixedUpdate() to feed both the input and the recorded positions and rotations to the vehicle. This will reproduce the recorded sequence with 100% precision.
I was told that physx should be deterministic along the same hardware vendor eg: along all intel CPUs.
Here’s a TLDR of what I’m doing. I have a server project and a client project. My cars are not deterministic at all, despite being the exact same prefab, ONLY on these projects.
I created TWO ENTIRELY new projects with nothing inside of them, put the car prefab inside both of them, and got deterministic results. The end values were 100% the same. So this doesn’t make any sense that I’m not able to get 1:1 results on my server and client project, but that I can get it on an entirely new project for some reason. I even spawned in a bunch of rigidbodies (not touching the cars) on my new projects, and it still produced deterministic results with the same inputs on the cars.
Also on my server project and client project, my main character moves with a rigidbody, however the results so far have been 100% deterministic. Should I be using something else to move him since physx isn’t deterministic along other CPU vendors? Like the character controller or something?