Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Third Party How to design an offline multiplayer game using Photon Unity Networking

Discussion in 'Multiplayer' started by ahsenarif, Feb 22, 2015.

  1. ahsenarif

    ahsenarif

    Joined:
    Feb 22, 2015
    Posts:
    2
    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.

    Code (CSharp):
    1. void Start () {
    2. spawnSpots =GameObject.FindObjectsOfType<SpawnSopt>();
    3. Connect ();
    4. //PhotonNetwork.CreateRoom("my");
    5. PhotonNetwork.JoinRoom("my");
    6. SpawnMyPlayer();
    7. }
    8.  
    9. void SpawnMyPlayer(){
    10. if (spawnSpots == null) {
    11. Debug.Log("No SpawnSpots Found");
    12. return;
    13. }
    14. SpawnSopt mySpawnSpot = spawnSpots[Random.Range(0,spawnSpots.Length)];
    15. GameObject myPlayerGO = (GameObject) PhotonNetwork.Instantiate ("PlayerController", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0);
    16. ((MonoBehaviour)myPlayerGO.GetComponent ("ThirdPersonController")).enabled = true;
    17. ((MonoBehaviour)myPlayerGO.GetComponent ("ThirdPersonCamera")).enabled = true;
    18. }

    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.
     
  2. gfoot

    gfoot

    Joined:
    Jan 5, 2011
    Posts:
    550
    Are you trying to do a local multiplayer option, with multiple players on one device? I don't think PUN will help much with that. As far as I know it assumes there is only one local player, whether you're offline or not. I could be wrong though, I haven't used it much.

    I also don't think PUN offline mode supports rooms. See here for some notes on offline mode: http://doc.exitgames.com/en/pun/current/reference/pun-and-un
     
  3. ahsenarif

    ahsenarif

    Joined:
    Feb 22, 2015
    Posts:
    2
    I am trying to make a multiplayer TD game for iOS/android that would allow the devices to connect using wifi/bluetooth . the multiplayer in essence means creating a co-operative environment over here. I was wondering if there is a way to achieve this without going into network of native android or iOS.
     
  4. gfoot

    gfoot

    Joined:
    Jan 5, 2011
    Posts:
    550
    Ah OK, I see what you mean now. My impression is that none of the Photon products support this - as far as I've seen they are all based, one way or another, on relaying traffic through a central server, either self-hosted or in "the cloud". You should use their forums to look for an authoritative answer though.
     
  5. Mikdad_Merchant

    Mikdad_Merchant

    Joined:
    Apr 10, 2015
    Posts:
    3
    I am looking for the same solution? did anyone find a solution
     
  6. jpthek9

    jpthek9

    Joined:
    Nov 28, 2013
    Posts:
    944
    DarkRift, Forge, uLink, and pretty much everything besides Photon has LAN capabilities because Photon is a very unique networking solution. Sorry for the grim solution, but Photon wasn't designed for locally hosted games so you'll need to use another networking solution.

    Actually, you can give players the Photon Redistributable server but that's very involved, especially if you want to make it user friendly.
     
    artanist likes this.
  7. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    @ahsenarif: PUN Offline mode is really offline. It can be useful if you want to create a singleplayer mode for a multiplayer game. It's behaving like the online mode but the client is alone in a (local) room without needing the connection.
    Photon does not support client-side hosting, so you always need a dedicated server in the LAN or other network. There is a Redistributable Server which you could hand out to players but of course that's less convenient than in-Unity hosting for LAN.
     
  8. testhon

    testhon

    Joined:
    Jan 19, 2018
    Posts:
    1
    As far as I know,photon server's loadbalancing feature can help in connecting local players..Correct me if I'm wrong
     
  9. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    Sorry but Photon does not help to connect local players.
    We got a service for Bolt, which helps Punch Through and does relay as fallback but that's currently specific to Photon Bolt.
     
  10. Ittahad

    Ittahad

    Joined:
    Jul 21, 2020
    Posts:
    1
    Is there any free library that I can use for local multiplayer networking ?
     
  11. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
  12. chloelcdev

    chloelcdev

    Joined:
    Sep 19, 2021
    Posts:
    7
    I don't mean to necro a thread but, in case someone comes along needing this info, and considering it was the first thing on google...

    why has no one here suggested simply having one "player" on the network but having 2 characters for the current player? It's really strange to me that the only response given here was "nope, not possible".