Photon PUN

Exemple of Photon PUN integration

This exemple is pseudo code giving an idea on how to implement our Network module. It may be different based on your Network Architecture and we recommend you to develop your own implementation.

PhotonConnectManager is a global script attached one time to get information if the local player joined a room and then instantiate its prefab.

Player is a script attached to the player prefab and will register and unregister if its local player or a remote player.

using Photon.Pun;
using Kinetix;
using Newtonsoft.Json;

public class PhotonConnectionManager : MonoBehaviourPunCallbacks
    // Called when local player joined room
    public override void OnJoinedRoom()
       GameObject gameObject = PhotonNetwork.Instantiate(PLAYER_PREFAB,, Quaternion.identity);
       Player player = gameObject.GetComponent<Player>();

Last updated