Problem replaying exactly same movement
Hi!
I'm working on a billiar similar 3D physics game. User shots a ball on a direction (this is the only interaction about user and objects in each movement) and, as a result, the ball could collide with another balls. I generate the initial movement with single AddForce event on ball's Rigidbody when user selected it, and Unity physics do the rest (no changes in any object Update or FixedUpdate).
The problem comes when I want to "replay" exactly the same movement. If I have exactly the same positions for each object, and I apply exactly the same force, in the same direction to the selected ball, the output result it's not always the same... sometimes, the difference is only by pixels, but deppending the force of the shot, or collision angle between objects, it change a little bit more.
What can I do?
I think that save all positions of all game objects during all movement in FixedUpdate, and later replay it, can't be a good solution. I need a stable physics environment that shows the same result with defined positions and an applied movement, because I need to share it between devices by Network.
Here I attach a simple example: 1 is the result of original movement. 2 is the result of the replayed movement.
Thank you very much!
Answer by aaubets · Feb 01, 2021 at 10:13 AM
Finally I decided to create a MemoryStream adding only the initial and end transforms of each ball, and all transforms of balls who modified their position during the movement.
Seems it works locally, over Network and between devices.
It's not the desired solution I was looking for, but it seems that MemoryStream don't takes a lot of size for each movement.