Photon PUN

Exemple of Photon PUN integration

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, Vector3.zero, Quaternion.identity);
       Player player = gameObject.GetComponent<Player>();
       player.Init()
    }	
}

Last updated

Was this helpful?