Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

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:
    37
    We are going to double-check this.
    Thanks for your feedback.

    --
    Ramon Melo
    Photon Team
     
  4. ramonsmelo

    ramonsmelo

    Joined:
    Jul 31, 2017
    Posts:
    37
  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:
    2,991
    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
     
    ramonsmelo and Lukeesta like this.
  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:
    37
    @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.

    --
    Ramon Melo
    Photon Team
     
  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:
    1
    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:
    37
    We usually reply within 24h, as it depends on the team timezone and if there is any holiday or weekend in the middle.

    --
    Ramon Melo
    Photon Team
     
  14. ramonsmelo

    ramonsmelo

    Joined:
    Jul 31, 2017
    Posts:
    37
    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?
    --
    Ramon Melo
    Photon Team
     
    Ed-Musayelyan likes this.
  15. khanhdtc3599

    khanhdtc3599

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

    m00seCS

    Joined:
    Jul 16, 2022
    Posts:
    2
    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,081
    No.
     
    m00seCS likes this.
  18. ramonsmelo

    ramonsmelo

    Joined:
    Jul 31, 2017
    Posts:
    37
    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.

    --
    Ramon Melo
    Photon Fusion Team
     
    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:
    2,991
    Thanks for the hint. We'll update the link.
     
    Last edited: Dec 14, 2022
  21. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,619
    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,619
    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:
    29

    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:
    4
    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:
    22
    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:
    4
    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:
    4
    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