Nullreferenceexception RPC

Options
Hi guys, I just want to execute an RPC, but, it keeps throwing a Nullreferenceexception.
This is my code:
void OnlineTime()
{
if (OpenManagerS.IsOnline)
{
if (StartLabelScript.Activator)
{
PhotonView PV = GetComponent< PhotonView >();
PV.RPC("RPC_OnlineTimer", RpcTarget.All);
//In this line throws the error ^
}
}
}
[PunRPC]
void RPC_OnlineTimer()
{
double elapsedTime = (PhotonNetwork.Time - TimeLeft);
double remainingTime = 1 - (elapsedTime % 1);
if (remainingTime <= 0)
{
WillKill = true;
SceneManager.LoadScene("GameOverScene");
}
}

Comments

  • SebGM2018
    Options
    Need to tell that the GetComponent() Line is incomplete, for some reason this webpage cut it. The complete line is:
    PhotonView PV = GetComponent();
  • SebGM2018
    Options
    Lol, Is GetComponent < PhotonView > ();
  • squirrel
    Options

    I know this is an old thread, but did you ever find a solution? I'm running into a similar situation.