Hello,
I'm curious about when to use Target.All vs using Target.Others, and what the delay is (if any) when sending an RFC to yourself.
For example, in my player input script, I don't want remote players controlling my character. So I perform the logic that converts input to movement, and use a tno.Send to tell the remote players how my character should be moving.
The question is: Is Target.All smart enough to instantly run the RFC on my local machine so there is no lag (waiting for the command to go to the server, then come back to me) before my character moves? Or do I need to just use Target.Others and then
also update my movement locally?
In other words, which of the following is necessary for there to be no delay between input and movement on the local machine?
void Update() {
// perform some logic determining dMov and other things first
// and then. . .
// send out the changes
tno.Send("SyncMovement", Target.All, dMov); // <-- does this get executed immediately on my own machine?
}
[RFC]
void SyncMovement(Vector3 deltaMovement) {
_char.deltaMovement = deltaMovement;
}
void Update() {
// perform some logic determining dMov and other things first
// and then. . .
// send out the changes to other players
tno.Send("SyncMovement", Target.Others, dMov);
// make the changes locally
_char.deltaMovement = dMov;
}
[RFC]
void SyncMovement(Vector3 deltaMovement) {
_char.deltaMovement = deltaMovement;
}
Note that in these examples, I'm not syncing position, I'm syncing movement/input (which direction the character should be moving continuously). In case that makes any difference.
And a follow up question: Can I call an RFC without actually making an RFC? e.g., can I do something like:
tno.Send(myRFC, Target.Others, arg);
myRFC(arg); // <-- will this execute locally?