Synchronization Issues (Unity + Photon): Part 5

We wrap up this series with an implementation of our theoretical solution to synchronizing items.

Image for post
Image for post

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

The Paddle

We will create a wall (as before) to abstractly represent the paddle controlled by the second application (right). In the first game (left), we will make the wall gray and disable the collider; we want the second application be authoritative about collisions between the ball and the wall.

Image for post
Image for post

note: At this point, we expect the balls to be out-of-synch.


Re-Synchronizing the Balls

The general idea is that we want to detect the collision between the ball and the wall (paddle) in the second game and send the information to the first game to re-synchronize the ball.

We add a Photon View to the Side prefab and add the following script.


With this in place, the applications behave as such:

Image for post
Image for post


  • The position of the balls are synchronized.

note: The only solution to the corner-case I could think of, is to break up the sides (top and bottom) into pieces and have the small pieces close to the wall (paddle) have the same treatment as the wall.

Hiding the Artifact

Struggled a bit to figure out how to hide the artifact, as it requires obscuring the ball and wall before the collision happens. One simple solution is to temporarily display a semi-transparent game object over the area of the artifact before the collision.

In this example, we create a Cube game object (turning it into a prefab, Obscure, in the Resources folder):

  • We position it as to cover the wall and space immediately around it


We then update GameManager.cs to instantiate the Obscure prefab on the first (left) application:


With this in place the applications behave as such; with the artifact mostly obscured.

Image for post
Image for post

Wrap Up

Hope you found this helpful.

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