- Home /
differentiate cloning objects with different tag names on PUNRPC
I try to change the tag names of instantiate game object on PUNRPC but it doesn't effect , tags names are not changing. This is the code i have used:-
IEnumerator SpawnPlayer(float respawnTime) {
yield return new WaitForSeconds(respawnTime);
int index = Random.Range (0, spawnPoints.Length);
player = PhotonNetwork.Instantiate ("A03", spawnPoints [index].position, spawnPoints [index].rotation, 0);
photonView.RPC ("PlayerTag", PhotonTargets.All, player);
[PunRPC]
void PlayerTag(GameObject player)
{
if (playerCount == 1)
{
player.tag = "One";
}
if (playerCount == 2)
{
player.tag = "Two";
}
}
Please send me the solution.
Calling this RPC should throw an exception because a type of GameObject is not serializable in PUN. Try sending for example the owner ID of the PhotonView component ins$$anonymous$$d. Within your RPC function you might iterate through all player objects and search for that one which matches the inco$$anonymous$$g owner ID. When having found the matching game object set its tag. $$anonymous$$ake sure that you already created the tag you want to use.
Your answer
Follow this Question
Related Questions
Photon Network Instantiate Objects over Network 1 Answer
Photon RPC methodcall 1 Answer
Proper way to instantiate projectile in PUN 1 Answer
Photon RPC "DestroyRpc" function not found 1 Answer
find GUIText 1 Answer