3

I am trying to make it where a certain number of players are required before the client sends everyone to the character select scene.

Within a function I have...

if (PhotonNetwork.PlayerList.Length == 1 & PhotonNetwork.IsMasterClient == true)
{
    PhotonView PV = PhotonView.Get(this);
    PV.RPC("heroSelect", RpcTarget.All);
}

Further in my code I then change the scene with...

[PunRPC]
void heroSelect()
{
    SceneManager.LoadScene(2);
}

I am getting "Object reference not set to an instance of an object" as an error on the line

PV.RPC("heroSelect", RpcTarget.All);
Tectrik
  • 61
  • 1
  • 5

3 Answers3

3

I figured out the problem.

In your hierarchy create an empty. I called mine NetworkManager. Add your script as a component. (You've probably already done these two steps.)

The important bit is this. Make sure you have a Photon View on your NetworkManager. Drag NetworkManager from the hierarchy onto Observed Components in the inspector. This should fix the error.

Tectrik
  • 61
  • 1
  • 5
0

You can set Observable Search to Manual

Jonas
  • 1
  • 1
0

I faced the same problem. The problem was solved by attaching PhotonView Component to the GameObject.