- Home /
Smooth client-side prediction with physics seems to be impossible in Unity
I am trying to do client-side prediction for a car vehicle, but the car acts incredibly unstable when I directly change the Rigidbody position and rotation manually to match the received server state and after that re-simulate the saved inputs. How can I correct the Rigibdoy state without this un-stability issue? Does this mean I can't do reliable and smooth client-side prediction with PhysX, and thus my only option is to use another physics engine? ,
Answer by Kakr-98 · Nov 05, 2020 at 05:31 PM
I found a workaround. To avoid this weird behavior, simply use MovePosition and MoveRotation and call Physics.Simulate for a very tiny delta after that (and then resimulate all saved inputs):
rigidbody.MovePosition(targetPos); rigidbody.MoveRotation(targetRot);
Physics.Simulate(0.00001f);