0
\$\begingroup\$

Here's a very simple class/call hierarchy:

public class NetworkPlayer : NetworkBehaviour {
    public static NetworkPlayer localPlayer {
        get;
        private set;
    }

    [Command]
    public void CmdTurnDone() {
        Debug.Log("Turn done! isServer "+isServer+" isClient "+isClient+" isLocalPlr "+isLocalPlayer);
    }
}

public class SomeMonoBehaviour : MonoBehaviour {
    void Update() {
        NetworkPlayer.localPlayer.CmdTurnDone(); 
    }
}

When Update() gets executed on the host, it outputs as expected:

Turn done! isServer True isClient True isLocalPlr True

Now, when Update() is executed on the remote client it outputs the following at the remote client's log only. However, the message does not appear at the server's logs:

Turn done! isServer False isClient True isLocalPlr True

What puzzles me is why the message appears at the remote client's log only.

If I'm not mistaken, calling CmdTurnDone() at the remote client should execute it on the server. But why does the log message appear at the remote client's log instead of on the server's logs - where it is executed? Is it valid to call CmdTurnDone() from a MonoBehaviour? Do you have any ideas why it's behaving like this? Is this the intended behavior? Thank you.

\$\endgroup\$
3
  • \$\begingroup\$ AFAIK, both your server and your client will do it separately, then the server will correct the client if there are any discrepancies between the two, but I can't really offer expert opinion. \$\endgroup\$ Dec 20, 2017 at 10:56
  • \$\begingroup\$ Oddly enough, no message shows up at the server's log as long as Update() is called on the remote client. It seems like it's executed on the remote client only. \$\endgroup\$ Dec 20, 2017 at 11:12
  • \$\begingroup\$ Unity's UNet stuff operates on magic. \$\endgroup\$ Dec 21, 2017 at 3:40

0

You must log in to answer this question.

Browse other questions tagged .