Network and RPC, in need of help (simple)

So, I’ve clustered my mind and think it’s best I asked for help.

I’ve got the rough basics of multiplayer up, several players, etc.
Here’s the problem:

I have two switches that will be “activated” for five seconds after they are pressed. If both two are activated in the same room of time, a door will open.

How would I proceed in doing this? I thought I had gotten a grasp of RPC, but seemingly not.

Feel free to COMPLETELY disregard my script since I’m obviously not right at all, but here’s what I’ve tried most recently (leaving out variable declarations):

The player (All doors and switches have the “door” tag and have a DoCalls() on them)

var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var hit : RaycastHit;
if (Physics.Raycast (ray, hit, 10)  Input.GetKeyDown("e")) {
	if (hit.collider.tag == "door"){
	hit.collider.networkView.RPC("DoCalls", RPCMode.All);
	}
}

On the switch. DoCalls runs SwitchPressed so in my theory all players would get one variable added.

@RPC
function DoCalls(){

 if (!switchDown){
 print("Pressed");
 switchDown = true;
 targetDoor.networkView.RPC("SwitchPressed", RPCMode.All);  
 WaitForSeconds(5);
 switchDown = false;
 }
}

Script on the door to be opened (the ‘doomdoor’)

@RPC
function SwitchPressed(){
 // This one is confusing, because seemingly when I press the button once, it gets run four times. i.e. //switchesPressed = 4 after one switch press

	print("Running Switchadder");
	switchesPressed++; 
	networkView.RPC("OpenDoor", RPCMode.All);
	yield WaitForSeconds(5);
	switchesPressed--;
        }

@RPC
function DoCalls(){
	
	if (switchesPressed == 2){

	lDoor.animation.Play("door3_open_l");
	rDoor.animation.Play("door3_open_r");

	}
}

your door is calling DoCalls also, which will trigger DoCalls on the door but also on the switch again. So you have a loop between the door and the switch.

so, if I understand correctly…

networkView.RPC(“DoCalls”, RPCMode.All);
will globally perform DoCalls on any gameobject with a DoCalls function attached in a script?

I’ll try it and report back.

I also realize I have a typo in the scrits, where it says SendMessage when it should be an RPC. Editing that

Nope, still the same result. Changed the code (updated first post).

I’m sure there is something about how RPCs work that I just don’t get.

RPCMode.All calls indeed on all the gameobjects that have the function. Try debug who is calling the rpc’s with NetworkViewID.

function DoCalls(viewID : NetworkViewID)
Debug.Log(viewID);

Thanks! Seemingly three instances are calling the function. The player pressing the switch, the other player (i.e. a “remote” player also on my pc for debugging) and a third part i cant quite figure out. “Scene ID: 6”.

I know my problem but I still don’t understand how I am supposed to limit it to just one call, from the interactor.
I will be trying to figure it out, but if anyone can help me out further it would be much appreciated.

NEVERMIND this silly thread of mine. I am humbled as I realized I haven’t fully understood how RPC works. I will do some studying before I try to approach this problem again.