How do I make fusion join a random room with active players?

Options

How do I make fusion join a random room with active players in it that doesnt have a session name like 693468978-6837-7358793587

Best Answer

  • Isaac_Augusto
    Answer ✓
    Options

    Hi,

    Currently, the session name is a GUID created by the matchmaking system.

    But, what you can do it's make your own flow to connect to a session. Like the following:

    • Try to connect normally to a random session, but with the DisableClientSessionCreation (I may have misspell the naming) attribute of StartGameArgs set to True.
    • Since now the client can't crate a session if none was found, it will throw an exception that no session was found.
    • You can now handle the exception and try to start a new game (with clients being able to create a session) with a new session name that you can generate... a 6 digits code for instance.

    -----

    Isaac Augusto

    Photon Fusion Team

Answers

  • Hey,

    You can just left the session field blank on the StartGameArgs when starting a game with GameMode.Client .

    GameMode.Client: Will join a random room, if no room was found, throws an exception.

    GameMode.AutoHostOrJoin: Will join a random room, if no room was found, It will create one.

    GameMode.Shared: Same as AutoHost.

    -----

    Photon Fusion Team

    Isaac Augusto

  • Hey, thanks for the response! I use shared and do just that for joining a random room but I was wondering if it is possible to have fusion generate a more simple room name when creating a room (if no room was found of course). From what I have seen it seems to generate very long complex session names when no session name is given. Example being something like: 67206702068-684936-6439869

  • Isaac_Augusto
    Answer ✓
    Options

    Hi,

    Currently, the session name is a GUID created by the matchmaking system.

    But, what you can do it's make your own flow to connect to a session. Like the following:

    • Try to connect normally to a random session, but with the DisableClientSessionCreation (I may have misspell the naming) attribute of StartGameArgs set to True.
    • Since now the client can't crate a session if none was found, it will throw an exception that no session was found.
    • You can now handle the exception and try to start a new game (with clients being able to create a session) with a new session name that you can generate... a 6 digits code for instance.

    -----

    Isaac Augusto

    Photon Fusion Team

  • Thank you very much for the help! One more question I'm still pretty new to fusion so this may he an obvious question but will fusion also throw an exception if the room has reached max players (set in network project config)? Thanks again for all the help!

  • Hey,

    Yes, it will.

    You can take a look on ShutdownReason.

    -----

    Isaac Augusto

    Photon Fusion Team