- Home /
Recursive Photon RPC call has same sender as first call
Ok, so I've been trying to come up with a solution for a large Photon-networked game that must be split into separate scenes. Photon is scene-blind, so that must all be handled by the client. I started diagramming what needs to happen for the scenes to be synced across the network and I decided on a call-return structure:
RPC "A" calls "SyncScene" on other views
"SyncScene" turns gameobjects on or off depending on scene and then triggers RPC "B"
RPC "B" calls "ReturnSyncScene" on the RPC "A" sender's view
"ReturnSyncScene" turns gameobjects on or off depending on scene
And here is the code I came up with:
[RPC]
void SyncScene(int sceneID,PhotonMessageInfo info){
for(int i=0;i<info.photonView.transform.childCount;i++){
info.photonView.transform.GetChild(i).gameObject.SetActive(sceneID==Application.loadedLevel); //set the sender's local children to be enabled or disabled depending on their relative scene
}
photonView.RPC("ReturnSyncScene",info.sender,Application.loadedLevel); //Send the sender our current scene
}
[RPC]
void ReturnSyncScene(int sceneID,PhotonMessageInfo info){
for(int i=0;i<info.photonView.transform.childCount;i++){
info.photonView.transform.GetChild(i).gameObject.SetActive(sceneID==Application.loadedLevel); //set the sender's local children to be enabled or disabled depending on their relative scene
}
}
void OnLevelWasLoaded(int level){
if(photonView.isMine){
photonView.RPC("SyncScene",PhotonTargets.OthersBuffered,level);
}
}
My problem comes in RPC "B". The sender should be the "other" views, but I'm debugging that my local view is the sending view - which seems impossible to me. Does anyone know what I'm missing? Am I using RPC's improperly?
Thanks!
EDIT: Fixed the code formatting
I tried suspending the RPC calls while switching scenes by using PhotonNetwork.is$$anonymous$$essageQueueRunning = false, but same results.
Your answer
Follow this Question
Related Questions
Update int value with photon rpc? 0 Answers
More efficient way to call these RPC's (Code works) 1 Answer
Proper way to instantiate projectile in PUN 1 Answer
Photon PUN2, Rpc score can't correctly. 1 Answer
Info on Photon PUN RPC calls. 0 Answers