Photon Pun 2
Laila Gamaleldin, Febraury 2021
Paul Molnar, March 2022
Background
Photon Pun 2 is a software development kit (SDK) and Unity plugin made by Photon Engine, a company that provides cross-platform multiplayer game backend as a service for synchronous and asynchronous games and applications. Photon Pun is closed source. Photon Pun 2 clones Unity's in-built networking API, which has since been deprecated, and uses Photon infrastructure to support it and make it reliable.
Use Case
Photon Pun is supposed to be one of the easiest multiplayer Unity plugins, and it's also among the most popular. It's good for student projects and hobbyists, but may not be the best option for more professional applications. Photon Pun caps games at a maximum of 20 players, which means that applications built using the plug-in do not scale very well. The reason why Photon Pun applications don't scale well is because Pun is built using mesh networking, which means that there is no single host/server that manages every user's instance; instead, every client manages its own synchronization logic. This means that as the game is scaled with more and more players each player has to store all of the information of all of the other players. Many other networking programs have a central server or system that tracks player movements and updates transformations, but Pun bypasses this relying on its clients to track each player. The lack of central authority also means that cheating is possible. Pun has mild latency, about 150-200 ms, which may or may not be acceptable depending on the application.
"Besides the omnipresent matchmaking, Pun basic building blocks are: serialization of game object states (with built in support for transforms)"
Cost
Photon Pun has both a free and a plus (paid) version. The free version allows up to 20 concurrent users. To go beyond that, developers need to purchase the plus version, which costs $95. Plus allows up to 100 concurrent users per month and charges $0.29 for every user beyond that. For larger games it may be worth it to try a different networking system or implement your own as loading 100 players into a game and forcing them to keep track of each other can result in slow runtimes and inefficient memory usage.
Community
Since Pun is closed-source, it's not possible to step through code and debug that way. Luckily, PUN has a very active community that is great at generating solutions to problems.
Questions and comments can be made through Pun's forum or its Discord. If those resources prove insufficient, Pun also has a developer support team that can be contacted at developer@photonengine.com.
Documentation
Thanks to its popularity, there is lots of documentation and many tutorials for Pun freely available on the internet.
YouTube Video: How to Make a VR Multiplayer Game - Part 1
This series has several parts and is very helpful for learning how to build a multiplayer VR game using Pun. There are problems from the first part that are solved in the second part such as adjusting transforms to account for global movement so it is recommended to watch several videos before trying to implement it.
Features
Room and Lobby Support
Filtering
Interest Management
Offline Mode
Relay
Multicast
WebGL
Unity 4 Free: Web Standalone
Unity 5
Playmaker Integration
Game Server plugins (enterprise cloud and self-hosted only)
Master Server
Custom Authentication
Webhooks and WebRPC
This website goes into more depth on Pun's features and compares it to another one of Photon's multiplayer Unity plugins.
Sources
Unity Networking Comparison Report
https://doc.photonengine.com/en-us/pun/current/reference/pun-vs-bolt