- Home /
Question by
aatya2006 · Nov 19, 2021 at 03:11 PM ·
networkingnetworkphoton
Photon PunRPC problem
I am new to multi-player so I am practicing by remaking among us and I have some troubles with PunRpc, the master client has a start button when it is pressed all the players should go to the spawn points in the same scene, But when this button is pressed it is sent to the master client only but it also dosen’t go to the spawn point
public void Mstart()
{
if (photonView.IsMine)
{
GetComponent<PhotonView>().RPC("startSend", RpcTarget.All);
}
}
[PunRPC]
public void startSend()
{
for (int i = 0; i < _theDoorsHide.Length; i++)
{
_theDoorsHide[i].gameObject.SetActive(false);
}
mapJoined = true;
_joined = true;
isStarted = true;
transform.position = _theRespawns[playerNum].transform.position;
transform.rotation = _theRespawns[playerNum].transform.rotation;
emergencyCount = 1;
randomTasks();
}
And I have troubles with syncing the player color
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if (stream.IsWriting)
{
stream.SendNext(playerMatMesh.color);
stream.SendNext(backMatMesh.color);
stream.SendNext(ghostMatMesh.color);
}
else
{
playerMatMesh.color = (Color)stream.ReceiveNext();
backMatMesh.color = (Color)stream.ReceiveNext();
ghostMatMesh.color = (Color)stream.ReceiveNext();
}
}
Comment