Search Unity

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

Third Party Photon Fusion

Discussion in 'Multiplayer' started by ramonsmelo, Apr 5, 2022.

  1. JamesBriggs

    JamesBriggs

    Joined:
    Jul 4, 2022
    Posts:
    4
    Heya, I'm currently implementing a Session List in a lobby and have the OnSessionListUpdated callback working which works for sessions which are created when the app is running, but its not fetching the sessions that were created before the app started running. I can't seem to find any GetSessionList() method or anything like that to fetch the pre-existing session list on initial connection so cant really get an accurate session list, do you have any advice for this?

    Thanks,
    James
     
    Last edited: Aug 30, 2022
  2. emreboran

    emreboran

    Joined:
    Feb 13, 2022
    Posts:
    3
    Hi
    How can I synchronize data in fusion?
     
  3. ramonsmelo

    ramonsmelo

    Joined:
    Jul 31, 2017
    Posts:
    39
    We are going to double-check this.
    Thanks for your feedback.

    --
    Ramon Melo
    Photon Team
     
  4. ramonsmelo

    ramonsmelo

    Joined:
    Jul 31, 2017
    Posts:
    39
    Last edited: Jun 14, 2023
  5. JamesBriggs

    JamesBriggs

    Joined:
    Jul 4, 2022
    Posts:
    4
    Thanks Ramon! If there's any workaround you and the team can think of as well to get an pre-existing session list then I'm happy to hear any ideas too.

    Cheers,
    James
     
  6. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    We release another sample: Fusion Golf

    The sample demonstrates an approach on how to create an arcade golf racing game with a focus on physics, using a server authoritative, client predicted model. It features a session browser as well as direct connecting via room codes. Hosts can modify various game settings such as max time per hole, max shots, whether or not players will collide with one another, and if the session is visible in the session browser. The sample has an 18 hole course with various physics-driven objects such as cannons, spinners, boost tunnels, and elevator platforms.
     
    Last edited: Aug 31, 2022
  7. JamesBriggs

    JamesBriggs

    Joined:
    Jul 4, 2022
    Posts:
    4
    Heya! I fixed my issue, turns out I was adding the callbacks for the OnSessionListUpdated after the lobby join, rather than between the runner creation and the lobby join, so it didnt get that initial call. Just thought i'd say here in case it helps anyone else, thanks for the help!

    Cheers,
    James
     
  8. mohsin199236

    mohsin199236

    Joined:
    Dec 3, 2018
    Posts:
    2
    Hi, i am developing a simple racing game for WEBGL. I'm encountering some issues.

    -When testing on my own system with multiple instances game runs fine on 2/6/8 player modes, but when i test it with remote players it start giving me errors.
    -Issues frequency increases in 6 and 8 player modes. In 2 player mode issues rarely happen. And when testing(2 player mode) with remote desktop user, issues vanish.
    -Players disconnect randomly with different shutdown reasons each time. DisconnectedbyPluginLogic, PhotonCloudTimeout, Error.
    -Sometimes upon entering a session player is instantly disconnected.

    What i've done:

    -Optimized my scene to around 300 batches.
    -Tried changing protocol from udp to tcp and websocket.
    -Studied fusion kart project to see if i'm doing something wrong.
    -Refactored my code to avoid abnormal behaviors when a user disconnects mid race.

    Any form of help is appreciated.

    @ramonsmelo

    @tobiass WhatsApp Image 2022-10-06 at 3.01.55 PM (1).jpeg WhatsApp Image 2022-10-05 at 6.28.26 PM.jpeg WhatsApp Image 2022-10-06 at 3.01.55 PM.jpeg WhatsApp Image 2022-10-06 at 3.06.59 PM (1).jpeg
     
  9. ramonsmelo

    ramonsmelo

    Joined:
    Jul 31, 2017
    Posts:
    39
    @mohsin199236

    For support, please send an email to developer@photonengine.com

    In that email, please reply with the following:

    - Which SDK Build are you using?
    - Are you using Shared or ClientServer Mode?
    - The full logs from your clients.
     
    Last edited: Jun 14, 2023
  10. mohsin199236

    mohsin199236

    Joined:
    Dec 3, 2018
    Posts:
    2
    How long does it takes to get a response from the email you mentioned? I already sent an email
     
  11. Ed-Musayelyan

    Ed-Musayelyan

    Joined:
    May 6, 2017
    Posts:
    2
    Hey guys! We are trying to implement host migration in our game and faced a problem with the host migration snapshot, which seems to contain only 1 networkObject no matter what.

    Our level loading flow, after the room is filled with players is like that:

    • Spawn gameplayContext (a network prefab with some top-level gameplay init logic) using Runner.Spawn
    • Load game level scene additively, then call RegisterSceneObjects for all scene networkObject
    • Spawn player character network objects for all players using Runner.Spawn
    So, this flow works fine and all the network objects are synced properly during gameplay. But now, when we are trying to implement host migration - the snapshot we receive always contains only 1 object (which is the first one spawned - gameplayContext, mentioned earlier).

    So, the main question is - why out migration snapshot does not include most of the loaded objects, despite those objects being synced properly before host migration happens?

    Maybe we missed some additional registration steps for those objects? Or do we need to call migration snapshot creation manually? (We are currently setting snapshot interval for 5 secs for testing purposes)

    We are using fusion 1.1.3 build 589
     
  12. JamesBriggs

    JamesBriggs

    Joined:
    Jul 4, 2022
    Posts:
    4
    Heya! I've got a vr app networked with Fusion Shared mode with meta avatars and about 30 grabbable objects with network transforms, It all works completely fine for about half an hour with ~10 people in it but then the network starts freezing up and stuff stops syncing or being able to be grabbed, suggesting lack of being able to access the network/request authorities. Are there any settings in the network project config that might be to do with this? Like it's exceeded the max amount of data or requests or something and locks up the server. It doesn't disconnect anyone from the server as it would do on an error, it just stops sending any new data or requests so it freezes everything up
     
  13. ramonsmelo

    ramonsmelo

    Joined:
    Jul 31, 2017
    Posts:
    39
    We usually reply within 24h, as it depends on the team timezone and if there is any holiday or weekend in the middle.
     
    Last edited: Jun 14, 2023
    valentin56610 likes this.
  14. ramonsmelo

    ramonsmelo

    Joined:
    Jul 31, 2017
    Posts:
    39
    You should be able to get all your NetworkObject just fine.

    We suggest reading the Host Migration doc entry and the Sample code.
    • Can you check with the latest SDK Build 599?
    • When running the
      runner.GetResumeSnapshotNetworkObjects()
      in order to get the NO list, does it contain only 1 NO, in your case?
    • In order to get the list of Scene Objects, you must use
      runner.GetResumeSnapshotNetworkSceneObjects();
      instead. When running it, what do you get?
     
    Last edited: Jun 14, 2023
    Ed-Musayelyan likes this.
  15. khanhdtc3599

    khanhdtc3599

    Joined:
    May 17, 2022
    Posts:
    1
  16. m00seCS

    m00seCS

    Joined:
    Jul 16, 2022
    Posts:
    4
    Is there a way to get Fusion to work for dedicated servers that don't communicate with Photon Cloud? Fusion looks appealing to us (we've even partially implemented it), but the ability for folks to set up offline LAN tournaments or community dedicated servers is important to the design of our game. Is support for that kind of thing planned?
     
  17. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,084
    No.
     
    m00seCS likes this.
  18. ramonsmelo

    ramonsmelo

    Joined:
    Jul 31, 2017
    Posts:
    39
    Communication with the Photon Cloud is mandatory.

    The Photon Cloud is also used for Matchmaking, connection handshake, as well as a relay service in case of direct connections are not possible.

    We do not have plans to make Fusion available in an offline format at the moment.
     
    Last edited: Jun 14, 2023
    m00seCS likes this.
  19. eli_123

    eli_123

    Joined:
    Oct 25, 2016
    Posts:
    5
    the link is broken
     
  20. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    Thanks for the hint. We'll update the link.
     
    Last edited: Dec 14, 2022
  21. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,635
    Everytime I try to join the discord server says invitation is invalid

    Anyways having a issue with using Shared GameMode

    runner.IsServer is returning false.
    I can't find any documentation on using shared mode?

    Code (csharp):
    1.  
    2.   async void StartGame(GameMode mode){
    3.       // Create the Fusion runner and let it know that we will be providing user input
    4.       _runner = gameObject.AddComponent<NetworkRunner>();
    5.       _runner.ProvideInput = true;
    6.       // Start or join (depends on gamemode) a session with a specific name
    7.       await _runner.StartGame(new StartGameArgs()
    8.       {
    9.         GameMode = mode,
    10.         Scene = SceneManager.GetActiveScene().buildIndex,
    11.         SceneManager = gameObject.AddComponent<NetworkSceneManagerDefault>()
    12.       });
    13.   }
    14.  
    15.     void Start () {
    16.         StartGame(GameMode.Shared);
    17.    
    18.     }
    19.  
    20.     public void OnPlayerJoined(NetworkRunner runner, PlayerRef player)
    21.     {
    22.      
    23.       if (runner.IsServer)
    24.       {
    25.            Debug.Log("test");
    26.  
    27.     }
    28.  

    Edit: Oh I see I guess im wanting IsSharedModeMasterClient

    is server is for if the client was acting as a server or if it was running on a server
     
    Last edited: Dec 27, 2022
  22. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,635
    How do I tell PhotonCloud to use a scene when the first person/masterClient enters
    Or how do I change scene I guess. Id like it to change scene before OnPlayerJoined is called.

    Code (csharp):
    1.  
    2.   async void StartGame(GameMode mode){
    3.       // Create the Fusion runner and let it know that we will be providing user input
    4.       _runner = gameObject.AddComponent<NetworkRunner>();
    5.       _runner.ProvideInput = true;
    6.       // Start or join (depends on gamemode) a session with a specific name
    7.       await _runner.StartGame(new StartGameArgs()
    8.       {
    9.         GameMode = mode,
    10.         Scene = SceneManager.GetSceneByName(GetRandomZone()).buildIndex,
    11.         SceneManager = gameObject.AddComponent<NetworkSceneManagerDefault>()
    12.       });
    13.   }
    14.  
    Ahh i just read the tooltip saying setting scene doesnt work on Shared/photon Cloud. So idk how do you have it change scene then at start
     
  23. Rashmika98

    Rashmika98

    Joined:
    Sep 24, 2022
    Posts:
    9
    Hi I have implemented a fusion code to enable an emote for the players in the game. At first, I did it with NetweorkMecanimAnimator as follows.

    Code (CSharp):
    1. networkMecanimAnimator.Animator.SetTrigger("Emote");
    However it didn't work as only the emote was visible to the player who enabled it. Then I used Rpc call to do the same operation in there the emotes were visible to only host (Other players couldn't see the emotes including their ones).

    Code (CSharp):
    1. [Networked(OnChanged = nameof(OnEmoteEnabled))]
    2.  
    3. public NetworkBool isPressed { get; set; }
    4.  
    5. [Rpc(RpcSources.InputAuthority, RpcTargets.StateAuthority)]
    6.  
    7.     public void RPC_EnableEmote(bool isPressed, RpcInfo info = default)
    8.  
    9.     {
    10.  
    11.         Debug.Log($"Called by {Object.Id}");
    12.  
    13.         this.isPressed = isPressed;
    14.  
    15.     }
    Glad if anyone can help me with this.
     
  24. Mike196

    Mike196

    Joined:
    Dec 30, 2022
    Posts:
    1
    Is Fusion the best system to use for a racing game with real physics and collisions or is Quantum better?
     
  25. DeathPro

    DeathPro

    Joined:
    Jul 28, 2018
    Posts:
    84

    You can try to change line 5 "RpcTargets.StateAuthority" with "RpcTargets.All". It should work then. The final look for line 5 should be:

    Code (CSharp):
    1. [Rpc(RpcSources.InputAuthority, RpcTargets.All)]
     
  26. N_Evan

    N_Evan

    Joined:
    Sep 17, 2021
    Posts:
    6
    Hello, I'm using Fusion for a small concept project where I need to spawn NPCs in sessions / game rooms and of course the NPCs of each room will be synced so that two players in the same room won't see NPCs at non-synced position. The pooling script is a network behavior, however when I try to get the reference of NetworkRunner and spawn an NPC by using Runner.Spawn, the Runner is always null. NetworkRunner is initialized in a previous scene and is persisting when new scenes are loaded. Maybe I'm missing something very silly. Some pointers towards the right direction would help a lot, thanks!

    Edit: One possible way is to spawn NPCs along with the OnPlayerJoined callback but I want the NPCs to start spawning when the room initially starts. It should not be tied with the joining or leaving or other players.
     
  27. Lukeesta

    Lukeesta

    Joined:
    Jan 7, 2016
    Posts:
    77
    Make sure you are using the runner.NetworkSceneManager to switch scene and not the regular Unity scene manager.

    Is the pooling script part of a scene which has been loaded via the NetworkRunner? If it is a scene object it either needs to be a `NetworkObject` (add the component) or it should be a `SimulationBehaviour` instead of a `NetworkBehaviour`.
     
  28. N_Evan

    N_Evan

    Joined:
    Sep 17, 2021
    Posts:
    6
    Thanks for the quick reply. My scene flow was,
    1. A lobby scene where the NetworkRunner is initialized with default parameters to join a common lobby.
    2. From the lobby players can create or join a session and is loaded into an empty loader / loading scene which is loaded through NetworkRunner.StartGame and a SceneController script loads rest of the scenes as per necessity (This is where I messed up I think as the SceneController here do not implement INetworkSceneManager and new scenes are loaded additively using UnitySceneManager here)
    3. The pooling script is in a third scene that is loaded additively and that scene is not loaded by the networkRunner. It is however a NetworkBehavior and has the NetworkObject component added to it.
     
  29. N_Evan

    N_Evan

    Joined:
    Sep 17, 2021
    Posts:
    6
    Hello again. I am still having a hard time getting my head around the scene loading part using Fusion. The `NetworkRunnerHandler` script from Menu scene initializes a `NetworkRunner` with `NetworkSceneManagerDefault`. When a player joins a session, the `runner.StartGame` loads up the next scene via given SceneRef. This new scene loaded is empty and used as a base for loading up other necessary scenes (still trying to piece out if this is a good or even half decent way of doing this.).

    After the new empty scene is loaded where do I go from here? The Scene Loading references provided still feels a bit vague and complicated, any pointers would be very much appreciated. Thanks!
     
  30. aydin_khp

    aydin_khp

    Joined:
    May 15, 2020
    Posts:
    29
    Hi Ramon,

    I am wondering how one could create a Global Network Object? Is a "Global Network Object" simply a "Network Object" with its DontDestroyOnLoad called or there is another way to create one? NetworkRunner has AddGlobal and AddOrGetGlobal methods which accept SimulationBehaviour but I don't think the network properties of a NetworkBehaviour would work if it gets added this way.

    Look forward to your response.

    Regards,
    Aydin
     
  31. saiyank

    saiyank

    Joined:
    Jan 13, 2021
    Posts:
    2
    Can dedicated server be built for android? if yes, then can someone say how?
     
  32. Lukeesta

    Lukeesta

    Joined:
    Jan 7, 2016
    Posts:
    77
    Yes you can build a server for android. However the platform is a bit limited:
    - You can't run it in headless mode as far as I know so there will always be graphics but you can just display a blank screen.
    - You cannot use the dedicated server target platform in the build settings. Just create a regular android build instead.

    And then to start Fusion simply start the runner in Server Mode.
     
    saiyank likes this.
  33. saiyank

    saiyank

    Joined:
    Jan 13, 2021
    Posts:
    2
    Thank you Lukeesta...
    then regular build with server mode, should that be put in server to keep that dedicated server for client mode builds to be connected under that? like the builds made for windows.
     
  34. Lukeesta

    Lukeesta

    Joined:
    Jan 7, 2016
    Posts:
    77
    I'm not sure I understand the question. Regular builds should be used for clients. For servers on windows/max/linux use the dedicated server platform.
     
    saiyank likes this.
  35. ramonsmelo

    ramonsmelo

    Joined:
    Jul 31, 2017
    Posts:
    39
    Hi Aydin,

    Sorry for the long delay.

    Yes, a "Global Network Object" would be just like any other `NetworkObject`, there is no special handling for cases like this. You just need to make sure it is not destroyed and you have only one copy of it.

    The NetworkRunner.AddOrGetGlobal is used internally to run the internal Fusion components, but can also be used to run logic within the Runner itself.
     
    Last edited: Jun 14, 2023
  36. Ceciaman

    Ceciaman

    Joined:
    Jul 30, 2013
    Posts:
    52
    Hi,
    I use Photon Fusion and Voice2 in Unity3d/Quest2 with metaAvatars.
    All works fine but when i use app i don't listen anything but see only lipsync.
    What can i do?
     
  37. sakandar_geniteam

    sakandar_geniteam

    Joined:
    Oct 3, 2023
    Posts:
    2
    Hi, i'm working Pool game. i use Fusion and implement Host Client topology. i have only one player ball at runtime which is synced through network. At start, player one has its state authority. I have turn management mechanism thorough which input should work for the player who has state authority. Now, i want to change the state authority at runtime and assign it to the other player when his turn comes.

    Please guide me how should i change state authority at runtime from Player 1 to player 2?
     
  38. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    In Host Mode, the clients never get state authority. They can request Input Authority.
    So when it's some players turn, that client should request Input Authority.
     
  39. AkilS1

    AkilS1

    Joined:
    Dec 1, 2023
    Posts:
    1
    Hi @tobiass , quick quesition - coming from a pun2 project - trying out the fusion package - Im not able to see any logs from the package - i.e - connecting to master server and connecting to room , etc -
    I have enabled logging to all in the photon settings - still I dont see any fusion logs - I see only my own logs.
     
  40. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    Check the Fusion entry in the Main Menu. There is an item to toggle Fusion to the debug libraries. That hopefully gives more info. If not, let me know and I'll ping the colleagues to reply.

    Somewhat off topic:
    When switching from PUN, I would recommend Fusion 2.x specifically. It has a much improved Shared Mode.
     
  41. BarisCrk

    BarisCrk

    Joined:
    Apr 7, 2014
    Posts:
    1
    Hi, i am using Photon Fusion with Dedicated Server option.
    Everything is perfect except, my server gets ''Reason: PhotonCloudTimeout'' at random times. I couldn't find any documentation about it.
    Except Photon Pun Troubleshooting: https://doc.photonengine.com/pun/current/troubleshooting/analyzing-disconnects
    And Photon Realtime Troubleshooting: https://doc.photonengine.com/realtime/current/troubleshooting/analyzing-disconnects

    But i think they are about Server-Client disconnects not PhotonCloudTimeout.

    My server gets PhotonCloudTimeout generally there is no player in it.

    I think my server has enough ram and processor power accourding this data below.
    ********
    Current FPS: 119 - Average FPS: 119
    Mono Memory: 18.0 / 18.1 MB (99.3%)
    Assets Memory: 611.8 / 751.0 MB (81.5%)
    System Memory: 31707 MB
    Graphics Memory: 128 MB
    ********

    My Fusion version is: 1.1.8
     
    Last edited: Jan 22, 2024
  42. ramonsmelo

    ramonsmelo

    Joined:
    Jul 31, 2017
    Posts:
    39
    Hi,

    The PhotonCloudTimeout might happen for different reasons but it means that either the peer (your Dedicated Server in this case) or the Photon Cloud could not communicate with that peer within a certain time, for Fusion, it is around 15 seconds of delay.

    This is usually caused by a lack of internet connection or some congestion in the communication, which is out of our control. But, as stated on the linked page, it can also happen the main tread is handing for some other reasons (scene or asset loading, for example).

    Those same instructions apply to Photon Fusion as well, as it uses Photon Realtime underneath.
    But Fusion already handles most of those scenarios automatically.

    That is an interesting point.

    If your server has been running for more than 24 hours without any cloud activity, such as players joining, it will be disconnected from the Photon Cloud. This is done to avoid maintaining unused resources.

    If you are experiencing this issue, it is expected, and you will need to handle it on your side by restarting the server.
     
  43. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,057
    Where and how do you host the dedicated server?