0% found this document useful (0 votes)
6 views24 pages

Metaverse - Day1 - PhotonServer

Metaverse _Day1_PhotonServer.pptx

Uploaded by

ideathonbcmx
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views24 pages

Metaverse - Day1 - PhotonServer

Metaverse _Day1_PhotonServer.pptx

Uploaded by

ideathonbcmx
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Build your Metaverse

Designed by MBCIE

Photon Server
Day 1 Connection

Dr Guolong Zhong
Nirmal
Introduction

• Interaction in Metaverse

• What is the Photon Server?

• How to use PUN in Unity

• Lab session

Image from Elena Nelyubina, istock


Introduction

Interaction in
Metaverse

• People • Concurrent players


(Avatars/Characters
• In a common space )

• Lobby and shared


• Communications virtual environment
• Chat/Events

Image from FreedomX, medium.com


What is the Photon Server/Engine?

What is the
Photon?

Photon is an on-premises* real-time socket


server and cross-platform multiplayer game
development framework.

By 2023, it is No.1 independent


cross-platform network engine.

*on-premises: The deployment of software happens in


the local environment (in-house).

on-cloud: on-demand computing services over the


internet
Photon Server

Photon Server vs. Photon


Cloud
Photon Server is a On Premise (OnPrem) server application that you can run and
host on machines of your choice – configured and set up, maintained by the users.

Photon Cloud is running on Photon Server. It is a Software as a Service (SaaS) and


as such a fully managed service – hosted and configured by the Photon Cloud service.
Photon Unity Networking (PUN)

Photon Unity Networking (PUN) is a Unity package for multiplayer


games.
It re-implements and enhances the features of Unity’s built-in
networking.
Photon Pun
With PUN, you already have a real dedicated server you can connect to and where rooms
actually exist. The client that creates a room is the first one to join it. It will be marked as a
Master Client known by everyone inside the room. A Master Client is not a host nor a
server but just a special client that can do extra stuff (pseudo-authoritative).

In Pun however, one of the Pun clients needs to act as a server, a true dedicated server or
real host. Ping and latency will depend on the connection to the hosting player.

More info:
https://doc.photonengine.com/en-us/pun/current/reference/pun-vs-bolt#:~:text=Photon%20Bolt%20is%20a%20higher%20level%20API%2C%20which,and%20associ
ate%20these%20assets%20to%20game%20objects%20prefabs.
Lab Session 2

Set Up Photon Server Connection


How to use PUN in Unity
1. Register a photon https://www.photonengine.
account com/
2. Find your PUN App ID and Chat ID in the
dashboard
How to use PUN in Unity
3. Create a project. Download PUN 2 assets in Unity Asset
Store, Import
How to use PUN in Unity
4. Photon Unity Networking
Wizard
How to use PUN in Unity
5. Photon Unity Networking Wizard
configure
Photon Server Region Map

Server
List
Region Location Token
Asia Singapore asia
Australia Melbourne au
Canada, East Montreal cae
Chinese Mainland1 (need Shanghai cn
separate id)
Europe Amsterdam eu
India Chennai in
Japan Tokyo jp
Russia Moscow ru
Russia, East Khabarovsk rue
South Africa Johannesburg za
South America Sao Paulo sa
South Korea Seoul kr
Turkey Istanbul tr
USA, East Washington D.C. us
USA, West San José usw

Ref: https://doc.photonengine.com/en-us/pun/current/connection-and-authentication/regions
How To Set Your Region

6. Set Your
Region

Best ping region – identify your best region –


Change fix region/dev region

Fix Region: in
Dev Region: in
Lab Session 1

7. Create a launch/loading scene (important for starting up a


server connection)

• Canvas
• Panel
• Raw image / loading animation
• Text
Lab Session 1

8. Create a Empty Game Object (ConnectToServer) and add a


C# script to it
Lab Session 1

9. C# script for setting up the connection

using Photon.Pun;
using UnityEngine.SceneManagement;
MonoBehaviourPunCallbacks
PhotonNetwork.JoinLobby();
Lab Session 1

10. Save Scene (name it as “Loading”). Create a new Scene


(“Lobby”). Create a Empty Game Object (CreateAndJoinRooms)
and add a C# script to it

• Canvas
• Panel
• Raw image / loading animation
• Text
• Button
• Input field
• Add function to button
Lab Session 1

11. C# script for creating and joining rooms

using Photon.Pun;
using UnityEngine.UI;
MonoBehaviourPunCallbacks

PhotonNetwork.CreateRoom()

PhotonNetwork.JoinRoom()

PhotonNetwork.LoadLevel()
Lab Session 1

12. Reuse PUN 2 demo scenes as the gaming scenes


Lab Session 1

13. Create a new C# script for QuitServer

using Photon.Pun;
using UnityEngine.SceneManagement;

MonoBehaviourPunCallbacks
PhotonNetwork.Disconnect()
Lab Session 1

14. Attach the quit room scripts to the button


Lab Session 1

15. Add “scenes in build” to build the Unity App


Lab Session 1

16.Test with two instances


Q&A
THANK YOU

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy