[Photon Pun] Only one player gets loaded into new scene. Why?

When the master client walks into the level loader object. It only loads the person who isn’t the master client into the new scene. Does anyone know what could cause this?
Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;

public class LoadLevel : MonoBehaviour
{
    public string levelName;

    private void Start()
    {
        PhotonNetwork.AutomaticallySyncScene = true;
    }

    private void OnTriggerEnter(Collider other)
    {
        Debug.Log("Level loaded was triggered");
        if ( other.CompareTag("Player") )
        {
            if ( !PhotonNetwork.IsMasterClient )
            {
                return;
            }

            Debug.Log("Loading new level");
            PhotonNetwork.LoadLevel(levelName);
        }
    }
}

I’ve been having the same problem and I’ve been trying to look everywhere for the fix If I find out how to fix it I will reply and tell you how to fix it

I don’t see anything obviously incorrect here.
Any errors on either client?

No errors, but looking at the hierarchy it seems like it is trying to load the level but gets stuck somewhere and gets into an infinite loading session. Maybe it’s to do with the fact that it’s trying to load the level twice?
9583069--1357081--upload_2024-1-15_10-8-5.png

It should be possible to avoid loading twice. Or is that by design?
PUN (out of the box) only supports actually changing the level, not re-loading one.

Definitely not by design. I don’t know why it was loading twice but I added a debounce timer to prevent it from loading multiple times in the same second and it fixed it. Thanks for your help.

1 Like