Manual Instantiation example in docs - why is PhotonPlayer sent in RPC?
Options
sosh
✭
Hi,
I'm looking the section titled "Manual Instantiation" at the end of this page:
https://doc.photonengine.com/en/pun/current/tutorials/instantiation
In the code (copied below), the PhotonNetwork.player is sent as a parameter to the SpawnOnNetwork RPC function, however it's not used (and not explained in docs).
Could anyone tell me why you would do that? Or what the original intention was in this code?
Thanks
I'm looking the section titled "Manual Instantiation" at the end of this page:
https://doc.photonengine.com/en/pun/current/tutorials/instantiation
In the code (copied below), the PhotonNetwork.player is sent as a parameter to the SpawnOnNetwork RPC function, however it's not used (and not explained in docs).
Could anyone tell me why you would do that? Or what the original intention was in this code?
Thanks
void SpawnPlayerEverywhere() { // You must be in a Room already // Marco Polo tutorial shows how to connect and join room // See: http://doc.photonengine.com/en/pun/current/tutorials/tutorial-marco-polo // Manually allocate PhotonViewID int id1 = PhotonNetwork.AllocateViewID(); PhotonView photonView = this.GetComponent<PhotonView>(); photonView.RPC("SpawnOnNetwork", PhotonTargets.AllBuffered, transform.position, transform.rotation, id1, PhotonNetwork.player); } public Transform playerPrefab; //set this in the inspector [RPC] void SpawnOnNetwork(Vector3 pos, Quaternion rot, int id1, PhotonPlayer np) //<--- np never used! { Transform newPlayer = Instantiate(playerPrefab, pos, rot) as Transform; // Set player's PhotonView PhotonView[] nViews = newPlayer.GetComponentsInChildren<PhotonView>(); nViews[0].viewID = id1; }
0
Comments
-
Hi,
PhotonPlayer added in sample code to show that it could be passed as RPC parameter if needed. If you do not use this parameter in RPC method, remove it to save bandwidth. Same applies to other parameters.0