Synchronization Issues (Unity + Photon): Part 1

The start of a series exploring synchronization issues in Unity and Photon through example.

Image for post
Image for post

As I suspect many other folks do, I thought to build my first multiplayer game as yet another Pong game. Everything went smoothly until I went to try to synchronize the movement of the ball between the two players.

Decided to step back from that project and first tackle this synchronization problem through a simplified example; documenting as I go.

Project Setup

Create and login to a Photon account. Create a new Photon application of type Photon PUN. Take note of its App ID; we will need it later.

Create a new Unity project based on the 3D template.

Using the Unity Asset Store, download and import Photon Unity Networking Free. We will use the App ID generated earlier to complete this step.

Table Scene

We, next, setup the Table scene with all the game objects; GameManager is an empty object at this point.

Image for post
Image for post

In order to allow the ball to bounce indefinitely, we create a Physics Material, Material, and apply it to the floor and sides.

Image for post
Image for post

Game Play

We create a Sphere, Ball:

  • In the middle of the floor

We create a script to join a Photon room on startup and add it to the GameManager game object.


We then create a script to set the ball in motion on a click and add it to the Serve game object and as the click handler for its Button component.


With this in place, we can run two instances of the application, e.g., can build a standalone application. When the second instance starts, it will join the same room as the first instance; enabling the Serve button there. Pressing the Serve button will set the ball in motion.

Image for post
Image for post


  • When the second player connects, the first player instantiates a networked Ball, i.e., the ball is created for all players in the room.

Next Steps

Having everything in place, we dive into synchronizing the ball’s movement in Synchronization Issues (Unity + Photon): Part 2.

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