I'm realizing simple 2D mmo game in Unity.
I want to implement user position synchronization between server and client. Which approach would you suggest?
My two approach ideas:
First one:
Description:
- ClientA generates event move. Delta time of his movement is 0 and send this event via socket as the command with the local timestamp of starting the movement (T1).
- Server will remember and broadcast for every client on scene about this event
- ClientB will receive the event of ClientA at (T3) time and implement movement action from dt (delta time) = T3-T1.
(we can also rate T3 and T1 in frames or server time).
Description:
- Every time we will be broadcast for clients current scene state
- Scene state will calculate on server or on client (it doesn't matter)
- ClientA will send to server move event and server will receive it and will remember it and broadcast to other clients.
- ClientB will get synchronized state of ClientA object and update their position using current movement state of the object) and interpolate that every time.
Well. Question is.... What pros and cons of this both solution will I get? And maybe you have the better solution than I think.
The solution might be on Unity engine but should be more effective than I figured out. Also, what solution uses Unity Networking and Photon with Photon server?
Thank you!