How do I sync Rigidbody2D over the network?
I've been working on a 2-player shooter-sports game prototype and I need to sync the ball (which has a Rigidbody2D attached to it) over the network. I managed to connect 2 players using Photon plugin for Unity. The players' Transform.Position sync smoothly over the network but the Ball's behavior is strange on the client side.
After searching for a solution I understood that because the Physics Engine is non-deterministic, there has to be a server for handling physics calculations, or one of the players (Host) should do the Physics calculations and other players simply "see" the result of the calculation on their screen.
I also saw a similar question here, one of the answers suggest using Smooth Sync Package from asset store. I'm not sure if it works in my case, I asked the support of the Smooth Sync Package and this was their answer:
If you are talking about great physics collisions like in Rocket League, the only way to do that would be to have everything owned by the server. With everything owned by the server, you'll have some latency when you want to move your objects so you'll probably want some great client-side prediction (player prediction) like Rocket League has. Smooth Sync (and every other Unity asset I know of) does not have client-side prediction though. If you are just trying to use RPCs to AddForce or set Velocity of a Rigidbody2D, it should work for that but keep in mind there is travel time between sending the RPC and it actually moving. Plus whatever you set InterpolationBackTime to in Smooth Sync. InterpolationBackTime intentionally sets objects in the past so that when a lag spike occurs, the object doesn't jitter at all and is always in a place it has been.
I cannot have my own server at the moment, so my Question is, What is the fastest way that I can implement the Rigidbody2D sync over the network? I'm not looking for precise collision detections, I just want an acceptable synchronization over the network.
PS: Here is the link to my playable prototype on itch.io
Your answer
Follow this Question
Related Questions
Assign Network Manager an Online Scene with Script 0 Answers
localScale in network 0 Answers
Unity Photon doesn't Spawn Player 0 Answers
How to use a script to control the nickname of online players 0 Answers
Instantiate with Photon 0 Answers