Problem in Joining A Random Game Session in Photon Fusion
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on Fusion.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Problem in Joining A Random Game Session in Photon Fusion
ChrisL
2023-03-30 12:53:40
hello I've been using the code in the photon fusion sample project Fusion Karts which was a kart racing game.
I modified a certain method in its GameLauncher class so I can use it for joining a random game session, but it only seem to always join the first session created in the lobby and not the other available sessions.
The problem arises when the first session is already in-game but the client is still always trying to join that game session.
The code goes like this.
public void JoinRandomRace()
{
SetConnectionStatus(ConnectionStatus.Connecting);
if (_runner != null)
LeaveSession();
GameObject go = new GameObject("Session");
DontDestroyOnLoad(go);
_runner = go.AddComponent
_runner.ProvideInput = _gameMode != GameMode.Server;
_runner.AddCallbacks(this);
_pool = go.AddComponent
Debug.Log($"Created gameobject {go.name} - starting game");
_runner.StartGame(new StartGameArgs
{
GameMode = GameMode.Client,
ObjectPool = _pool,
SceneManager = _levelManager,
PlayerCount = ServerInfo.GameMode == 0 ? ServerInfo.MaxUsers : ServerInfo.MinUsers
});
}
Comments
Isaac_Augusto
2023-04-10 12:06:06
Hi ChrisL, Sorry for the delay.
I suspect you're not closing the session when the game starts?
Joining a random session will try to join the first session it's was able to, so if you're not closing the session, client's will keep trying to join.
I believe it's something along these lines:
// When don't expecting more clients to join
Runner.SessionInfo.IsVisible = false;
Runner.SessionInfo.IsOpen = false;
Not sure about the syntaxes though.
Isaac Augusto
Photon Fusion Team
Back to top