Hi! I'm somewhat new to PUN and Unity so hopefully I am making some kind of beginner mistake.
void Update(){
if(launch == true){
Debug.Log("launched");
myPhotonView.RPC("ChangeScene", PhotonTargets.All);
}
//myPhotonView.RPC("ChangeScene", PhotonTargets.All);
}
When I run the code above, I can see launched in the console but I get "NullReferenceException: Object reference not set to an instance of an object" on this line: myPhotonView.RPC("ChangeScene", PhotonTargets.All);
When I run it with that line commented out and the line that's outside the if statement uncommented, there is no null reference exception and the method executes. Is there a mistake in the above code, or is this a bug in Photon? Any help at all is much appreciated. I can post the full code or error messages if anyone think it's necessary.
Also, this is less important, but myPhotonView is null in any methods I create that aren't regular monobehaviour methods like Start or Update even though I set it as a global variable and filled it in Start before I try to access it. This seems like it might be tied to the other problems I'm having.
void Update(){
if(launch == true){
Debug.Log("launched");
myPhotonView.RPC("ChangeScene", PhotonTargets.All);
}
//myPhotonView.RPC("ChangeScene", PhotonTargets.All);
}
When I run the code above, I can see launched in the console but I get "NullReferenceException: Object reference not set to an instance of an object" on this line: myPhotonView.RPC("ChangeScene", PhotonTargets.All);
When I run it with that line commented out and the line that's outside the if statement uncommented, there is no null reference exception and the method executes. Is there a mistake in the above code, or is this a bug in Photon? Any help at all is much appreciated. I can post the full code or error messages if anyone think it's necessary.
Also, this is less important, but myPhotonView is null in any methods I create that aren't regular monobehaviour methods like Start or Update even though I set it as a global variable and filled it in Start before I try to access it. This seems like it might be tied to the other problems I'm having.