- Home /
Unity networking RPC problem- Photon
Hello guys,
I'm trying to call an RPC and it just isn't executing. If I do the exact same thing without an RPC it works fine but I need all the players to instantiate the text. Is there some reason why this wouldn't execute? I get no error message except this:
NullReferenceException: Object reference not set to an instance of an object
private void GameStart()
{
photonView.RPC("SpawnText",PhotonTargets.All);
}
[RPC]
public void SpawnText()
{
timer = PhotonNetwork.Instantiate(timerPrefab.name, timerPrefab.transform.position, timerPrefab.transform.rotation, 0);
timerText = timer.GetComponent<TextMesh>();
timerText.text = null;
questionMain = PhotonNetwork.Instantiate(questionMainPrefab.name, questionMainPrefab.transform.position, questionMainPrefab.transform.rotation, 0);
questionMainText = questionMain.GetComponent<TextMesh>();
questionMainText.text = null;
}
Thanks!! Chris
What line launches this error ? This is always helpful to have the line
The full error message is this: NullReferenceException: Object reference not set to an instance of an object SpawnScript.GameStart () (at Assets/Scripts/SpawnScript.cs:80) GameEvent$$anonymous$$anager.TriggerGameStart () (at Assets/Scripts/Epito$$anonymous$$e_Scripts/GameEvent$$anonymous$$anager.cs:10) GUI$$anonymous$$anager.Update () (at Assets/Scripts/Epito$$anonymous$$e_Scripts/GUI$$anonymous$$anager.cs:18)
When I double click it - it takes me to this line of code: photonView.RPC("SpawnText",PhotonTargets.All);
Thanks! Chris
Do you have a photon view attached to the game object which contains this script ? If not this is the problem, you can't send a RPC call without it.
Your answer
