[Tutorial] Unity v2019.1.1f1 & PUN 2 Multiplayer Networking Series

13th May 2019   Game Development

 

Have you ever thought of making a multiplayer game using Game Engines like Cry or Unity? You might be wondering how hard it is to create such games. Well, as a matter of fact, creating multiplayer games is not that hard to do. Especially if the API that you’re using provides documentation that is very easy to understand.

There is a number of services that can help you with server hosting. One of them is Photon Network also known as PUN. Short of Photon Unity Networking.

What is Photon Unity Networking?

Photon is a real-time multiplayer game development framework that is fast, lean, and very flexible. It consists of a server and multiple client SDKs for major platforms.

What are the features of PUN?

If you are wondering about the features of Photon Unity Networking. They provide:

  • A very easy to learn API
  • Lots of demos and an extensive PUN Basics Tutorial
  • Server available as hosted service (free for development) or as “On-Premise”
  • Load-balanced! Scales across servers (with no extra effort)
  • Outstanding performance of the Photon Server
  • Dedicated servers. No NAT punch-through needed
  • Offline mode: re-use your multiplayer code in single player game modes

What is the latest release of PUN?

PUN 2 is the latest release of their API which has been improved a lot compared to their last release. Unlike the previous one, this latest version is much more secure and easy to code. Although they’ve changed a lot of function calls they are pretty much easy to remember.

So if you are used to the previous version of PUN, migrating to this newer version won’t be that hard to do.

In this article, we’ll be guiding you on how to use Photon Unity Networking (PUN 2) with Unity 2019.1.1f1.

Download and Import PUN 2

To download Photon Unity Networking, follow the steps below:

  1. In your Unity Editor, open up Asset Store by clicking on Window tab and click Asset Store or you can do a shortcut by pressing Ctrl + 9.

    Open Asset store in Unity Editor
  2. Next, click on the search bar and type PUN 2.
  3. Choose PUN 2 -FREE

    download photon unity networking 2
  4. Once opened, click download and wait until you can import.

    Import PUN 2 to your unity project

Now before we proceed, we have to create first a Photon App ID. You can do this by going to their official website at photonengine.com.

Once arrived, log in with your account or if you haven’t registered yet, do so by clicking on Sign up.

Next, once you’re logged in and arrived at the dashboard. Click Create a New App like what’s seen in the image below.

Create new app in Photon

After clicking the button, fill in the form like what you’re seeing in the image below:

For Photon Type: Choose Photon PUN or Photon Realtime
Name: Name of your Project
Description: Any description you want or you can leave this empty
URL: leave this blank

Once done, click create.

Form for New App ID creation for Photon Unity Networking

 

Look for the panel like below and copy the App ID. Make sure it has the same name as the one you have typed in the form.

Photon Unity Network App ID Creation Guide

Next, go back to your Unity Editor and Paste the App Id in the window like what you’re seeing in the image below:

Photon Unity Network Setup Wizard example

Remember, you’ll only see this wizard above after you imported PUN 2 from the asset store. If somehow, you don’t see this or you have accidentally skipped the wizard, you can find the server settings in folders path:

Assets > Photon > PhotonUnityNetworking > Resources and click PhotonServerSettings and just paste the App ID in the App Id Realtime input box like below.

Example of Photon Server Settings of Photon Unity Networking

That’s it! Now you have successfully connected your game with Photon Network.

Conclusion

Now that we have successfully connected our Unity Project with Photon Networking, we can now create a lobby and room where other players can join.

In the next tutorial, we’re going to setup our lobby using UI canvas and other components provided by Unity. To proceed click the next article below:

React to this topic
Bernard Polidario
About Bernard Polidario

A full-stack developer who has been around programming community for 10+ years and still has a lot of passion for programming and design. I am the founder of WeeklyHow and I can be reached at [email protected]

https://weeklyhow.com

4 comments on [Tutorial] Unity v2019.1.1f1 & PUN 2 Multiplayer Networking Series

  1. Thanks a lot for all your tutorials! They are well done and help us a lot building our game!
    Thank you again for your work!

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*
*