Synchronization Issues (Unity + Photon): Part 4

Beginning to explore a completely different approach to synchronizing.

Image for post
Image for post

This article is part of the series starting with Synchronization Issues (Unity + Photon): Part 1.

Sidebar into a Photon Provided Solution

In researching the specifics of the theoretical solution to problems arising from network lag (from last article), I bumped into an article written by Photon on the topic; Lag Compensation.

The solution amounted to writing a custom Observed Component that behaves much like the Photon Transform View (position synchronization) and Photon Rigidbody View (velocity synchronization) used together; but with an extra compensation for network lag.

Image for post
Image for post

Assets/Table/Ball.cs

The resulting behavior was:

Image for post
Image for post

Observations:

  • First, the movement of the balls in the two applications is indeed more synchronized

Synchronizing Initial Movement

Here we are going to take a dramatically different approach by first getting rid of the networked ball from our earlier example:

  • Remove the line instantiating the ball in OnPhotonPlayerConnected in GameManager.cs

Now, we go back and recreate the ball (Ball) in the scene; just a plain-old game object with a Rigidbody component.

The next steps enables the Serve button to do two things:

  1. Start the movement of the ball in the local application

First, we add a Photon View component to the Serve game object. We then update Serve.cs.

Assets/Table/Serve.cs

With this in place we see that that the two balls are synchronized with no unusual artifacts like we saw in the previous example.

Image for post
Image for post

If, however, if we left this running for a long time we would expect the positions of the ball to slightly drift as the balls’ positions are never re-synchronized.

Next Steps

In the next article, Synchronization Issues (Unity + Photon): Part 4 we will work in synchronizing collisions (with the paddles).

Written by

Broad infrastructure, development, and soft-skill background

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store