Search Unity

DESPERATE problem Command not execute from client

Discussion in 'Multiplayer' started by pKallv, Mar 8, 2017.

  1. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,190
    Suddenly, it worked this morning, I am not able to send commands from Remote-Client Player and I have no idea why? It work with Host-Client Player (Red). I desperately need to solve this ASAP.

    Here is the basic code:

    Code (CSharp):
    1. public void On_1f_TouchStart (Gesture gesture) {
    2.         //print ("On_1f_TouchStart");
    3.  
    4.         if (!isLocalPlayer)
    5.             return;
    6.  
    7.         if (!hasAuthority)
    8.             return;
    9.         print("Print Cmd_FFF ('DD')");
    10.         Cmd_FFF ("DD");
    11.  
    12.  
    13. [Command]
    14.     void Cmd_FFF (string fff) {
    15.         print ("Cmd: " + fff);
    16.     }
    Red player is host-client and Blue player is remote-client.

    Result from Host-side-client in editor:
    Result when running remote-client on Editor, Cmd is never processed:
    Command sent from Player, see settings:
    uploading pictures

    Anyone that have any ideas why this may happen? Could it be so that the network is not properly configured or not active? I get no messages in the console and it worked earlier today.

    Could it be a bug?

    Any help or ideas will be HIGHLY appreciated!
     
    Last edited: Mar 8, 2017
  2. angusmf

    angusmf

    Joined:
    Jan 19, 2015
    Posts:
    261
    That's the correct behavior. The command will only run on the server (host.) That's what a command is for. When you see "Print Cmd_FFF ('DD')" on blue, you should see Print Cmd_FFF ('DD') on red.
     
  3. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,190
    @angusmf Thanks for responding. I think i was not clear in my description. The results is when i click on respective side. I am configuring so the host is on the player i generate and use the remote-client in the editor, which generates the print. I have also tried with tracing and trigger/trap the code but it never hits the Cmd-code. Updated the question above.
     
  4. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,190
    Found this in the log, maybe it has something to do with this:

     
  5. TheLastVertex

    TheLastVertex

    Joined:
    Sep 30, 2015
    Posts:
    126
    You should never see the [Command] print unless the Host is running in the editor. The Cmd will always be executed on the server.

    Thus when the Host is in the standalone, and the Remote-Client is in the editor. The Cmd Print is printed on the Standalone, the version that doesn't have the debug log for you to see it.

    That doesn't' mean its not being executed though.
     
  6. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,190
    tx. However, i have tried all kind of things without it executing the Cmd and now it working suddenly again??? ...i did not change in the code except putting in prints trying to step the code. No additional code lines. I am confused, but happy it working again. I have checked all the settings including the service. I have restored the same last version from Collaborate approx. 10 times. Maybe it has something to do with that, who knows?? Again, tx for your help.
     
    Last edited: Mar 8, 2017
  7. NGC6543

    NGC6543

    Joined:
    Jun 3, 2015
    Posts:
    228
    Hi, I'm having a similar issue here.
    I built a client on an iOS device and run Unity Editor as a server.
    The client calls the [Command] methods, but it's executed on the client not on the server. The debug message is shown on the client(iOS) not server(Unity Console)..
     
    Nananaaa likes this.
  8. Nananaaa

    Nananaaa

    Joined:
    Jul 24, 2016
    Posts:
    31
    Have you figured out why the command was executed on the client only? I'm just struggling with the same behaviour...
     
  9. Nananaaa

    Nananaaa

    Joined:
    Jul 24, 2016
    Posts:
    31
    I had a similar issuer, when the [command] was executed from the context of a MonoBehaviour - i.e. from inside a MonoBehaviours Update() function. What fixed it, was to ensure the [command] gets executed from inside its NetworkBehaviour's Update() function.