Networking Issue Client Side
Options
What could be the reason for client's transform not updating in master server?
These 4 RPCs has been called in my script. But still if a player in client-side move, it is not updating in server but server-side movements are updating in client. Somebody please help!
These 4 RPCs has been called in my script. But still if a player in client-side move, it is not updating in server but server-side movements are updating in client. Somebody please help!
if (PlayersInGame==1) { PhotonView.RPC("RPC_SpawnPlayerCamera",PhotonTargets.MasterClient); PhotonView.RPC("RPC_SpawnPlayers",PhotonTargets.MasterClient,id1); PhotonView.RPC("RPC_AssignPlayerButtons",PhotonTargets.MasterClient); } else if (PlayersInGame==PhotonNetwork.playerList.Length) { PhotonView.RPC("RPC_SpawnTargets",PhotonTargets.MasterClient,id2); PhotonView.RPC("RPC_SpawnTargetCamera",PhotonTargets.Others); PhotonView.RPC("RPC_SpawnTargets",PhotonTargets.Others,id2); PhotonView.RPC("RPC_AssignTargetButtons",PhotonTargets.Others); PhotonView.RPC("RPC_SpawnPlayers",PhotonTargets.Others,id1); print("All players are in game"); }
0
Best Answers
-
Hi @degeta10,
please don't double or even triple post the same problem, as this makes things more complicated and confusing. I have also noticed your other post including the entire source code of the certain class.
I must admit that all those RPC calls are very confusing for me, you should find a way to clean things up. You can for example setPhotonNetwork.automaticallySyncScene = true;
to make sure that each client in the room loads the same scene. You can also use the OnSceneFinishedLoading callback to set Custom Player Properties for example. Using this you can let each other client know, that your local has loaded the scene without using RPCs. When all clients are ready, either the MasterClient can set up the game or each client can get their objects. You would also have the option, to prepare everything in the Unity Editor and request Ownership of the object at runtime.5 -
Hey actually i found the problem. I used this function to spawn just one prefab when each player connects and its working. Because i used PhotonNetwork.Instantiate it worked. In my games script i manually spawn the players using just Instantiate method and its not wokring. So What should i do?
[PunRPC] private void RPC_SpawnPlayer(int id1) { float randomval=Random.Range(0f,5f); PhotonNetwork.Instantiate(Path.Combine("Prefabs","Player"),Vector3.up*randomval+Vector3.right*randomval,Quaternion.identity,0); }
0
Answers
-
Hi @degeta10,
please don't double or even triple post the same problem, as this makes things more complicated and confusing. I have also noticed your other post including the entire source code of the certain class.
I must admit that all those RPC calls are very confusing for me, you should find a way to clean things up. You can for example setPhotonNetwork.automaticallySyncScene = true;
to make sure that each client in the room loads the same scene. You can also use the OnSceneFinishedLoading callback to set Custom Player Properties for example. Using this you can let each other client know, that your local has loaded the scene without using RPCs. When all clients are ready, either the MasterClient can set up the game or each client can get their objects. You would also have the option, to prepare everything in the Unity Editor and request Ownership of the object at runtime.5 -
Hey actually i found the problem. I used this function to spawn just one prefab when each player connects and its working. Because i used PhotonNetwork.Instantiate it worked. In my games script i manually spawn the players using just Instantiate method and its not wokring. So What should i do?
[PunRPC] private void RPC_SpawnPlayer(int id1) { float randomval=Random.Range(0f,5f); PhotonNetwork.Instantiate(Path.Combine("Prefabs","Player"),Vector3.up*randomval+Vector3.right*randomval,Quaternion.identity,0); }
0