- Home /
Really quick/easy question about RPCs
quick question
All the client and the server have the same script attached.
var vartosend = int;
var vartorecieve = int;
@RPC
function sendvar () {
vartosend = vartorecieve;
}
i have a question about RPCMode.Server.
networkView.RPC("sendvar", RPCMode.Server);
Does this make :
the servers vartosend = the clients vartorecieve
the clients vartosend = the servers vartorecieve
the servers vartosend = the servers vartorecieve
Which one of these does the code do? Thank your for your time.
Have a Quishtay™ Day.
Answer by Owen-Reynolds · Nov 28, 2013 at 06:37 PM
The last one.
The only data being sent between computers is the stuff inside the RPC call. So your RPC is sending no data; just "hey, run your sendVar function." To send something, write sendvar
to have an input (see the docs.)
Background: to get an int on my computer, over to your computer, it takes a few steps. It has to be packed into bytes, marked as low or high digit first ("endian",) marked as an int added to a network packet, addressed and mailed. The RPC command does that with everything inside the ()'s, except the RPCMode -- that just tells it how who to mail it to. When the server (or anyone) gets it, it unpacks it all. That's the only way it gets data. Maybe it sees "sendvar", 34. It turns that into sendVar(34)
and runs it.
Your answer
Follow this Question
Related Questions
Get RPC senders ID, or IP? 1 Answer
Joining a Running Server (Game) and Waiting for Game State Data. How? 1 Answer
Networking RPC calls never sent to other clients 1 Answer
network.RPC behavior 1 Answer
Send Texture Over Network 1 Answer