Key Topics

Exploring PUN2 for Seamless Multiplayer Connections


Development Summary

Exploring PUN2 for Seamless Multiplayer Connections

Photon Unity Networking

Untitled

Untitled

Photon Unity Networking, or PUN, is a networking framework for Unity, which allows real-time communication between users. It is a third party library that allows developers to easily implement networking system into their projects. PUN offers various features that enable easier network programming, including player synchronization, remote procedure calls (RPCs), and room management. It also provides independent modules that easily synchronises the following:

PUN2 library also provides a module called PhotonView which identifies an object across network and configures how the controlling client updates remote instances. For example, a simple GameObject, say a sphere, is to be created on the scene while two users, A and B, are connected to the same scene.

A sphere instantiated by the user A without PhotonView component (i.e. not identifying it as a network object) will only be created on the controlling client and will not appear on the user B’s screen. However, if a sphere is instantiated with PhotonView component, it will not only appear in both users A and B’s screens but also when another user C joins the scene, it will be on the user C’s screen as well.

photon sync.mp4

The video above shows two different instances in the same Photon room. A cube owned by each instance is highlighted in blue. It demonstrates a simple transform synchronization using the Photon Transform View component.

Remote Procedure Call