RPC NullReferenceException: Object reference not set to an instance of an object
INTODAN
✭
Hi everyone, there was a tread about this problem but the thread did not help me. Here is a link to it. The ultimate solution was that the RPC was called by a child of the object that has the photon view compoment but in my case that is not the problem. I am trying to Instantiate a bomb that the player throws. The bomb variable is a prefab.
Here is my code:
I debugged the code and turns out that the argumentsTypes array is null. Can anybody help me?
Here is my code:
private void FixedUpdate() { if (!photonView.IsMine && PhotonNetwork.IsConnected == true) return; if (shouldThrow) { shouldThrow = false; gameObject.GetComponent<PhotonView>().RPC("createBomb", RpcTarget.AllViaServer); } } [PunRPC] public void createBomb() { GameObject c4 = Instantiate( bomb, new Vector3(camera.transform.position.x, camera.transform.position.y, camera.transform.position.z), Quaternion.Euler(camera.transform.rotation.eulerAngles.x, camera.transform.rotation.eulerAngles.y + 90, camera.transform.rotation.eulerAngles.z) ); c4.transform.position += camera.transform.forward; c4.GetComponent<Rigidbody>().AddForce(camera.transform.forward * speed); c4.GetComponent<Rigidbody>().AddForce(new Vector3(0, up, 0)); }The error is in line 508 in the script PhotonNetworkPart:
for (int index = 0; index < argumentsTypes.Length; index++)
I debugged the code and turns out that the argumentsTypes array is null. Can anybody help me?
0
Best Answer
-
Hi @INTODAN,
Thank you for choosing Photon!
What PUN2 version are you using?
Could you update to 2.15 (latest) as it fixes the NullReferenceException as you can see in the version history?v2.15 (19. September 2019)
Fixed: NullReferenceException when trying to log an error for a received RPC with a non existing method and zero arguments.5
Answers
-
Hi @INTODAN,
Thank you for choosing Photon!
What PUN2 version are you using?
Could you update to 2.15 (latest) as it fixes the NullReferenceException as you can see in the version history?v2.15 (19. September 2019)
Fixed: NullReferenceException when trying to log an error for a received RPC with a non existing method and zero arguments.5