Search code examples
unity-game-enginemultiplayerphoton

How to design an offline multiplayer game using Photon Unity Networking


I have designed a multiplayer game in Unity 3D using Photon Unity Network plugin for multiplayer gaming. It is working fine in the online mode. I want the same multiplayer game running offline without the Photon cloud. I want all the players to join to the same room. But when I run the code below I can see only my player but not any other player.

void Start () {


        spawnSpots =GameObject.FindObjectsOfType<SpawnSopt>();
        Connect ();
        //PhotonNetwork.CreateRoom("my");
        PhotonNetwork.JoinRoom("my");
        SpawnMyPlayer();
    }

void SpawnMyPlayer(){

        if (spawnSpots == null) {
            Debug.Log("No SpawnSpots Found");
            return;
        }

        SpawnSopt mySpawnSpot = spawnSpots[Random.Range(0,spawnSpots.Length)];

        GameObject myPlayerGO = (GameObject) PhotonNetwork.Instantiate ("PlayerController", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0);
        ((MonoBehaviour)myPlayerGO.GetComponent ("ThirdPersonController")).enabled = true;
        ((MonoBehaviour)myPlayerGO.GetComponent ("ThirdPersonCamera")).enabled = true;

    }

I am trying to join all the players to the same exact room. But why it is not happening?

Please note that I am talking about Photon offline mode and I don't want to make my game single player. I want an offline multiplayer game.

Thanks in advance.


Solution

  • The documentation talks about Photon offline mode being specifically for easily making a single player version of your photon online game. It is not for 'local multiplayer'. It is NOT going to connect you with other players in any way.