Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Command Cmd<Function> called on server... But it's a client? Using NetworkTransport only.

Discussion in 'Multiplayer' started by FuzzyQuills, Oct 20, 2017.

  1. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Hello all, I am implementing my own networking solution using just the NetworkTransport, and so far have transform syncing, spawn and destroy all working.

    However, I've run into a small, perhaps big, problem; RPC calls. Short of implementing my own, I googled around to see if some HLAPI functions would work, and apparently, someone did get [Command] and [ClientRpc] working, so I had a shot at writing my player script to use them.

    I tried this though, and although I'm sure my client binary is setup as a client socket, calling a command spits out that error message. Is there some additional setup needed to tell unity it's a client, not a server? (I also tried ClientRpc by itself, and as expected, it reported calling clientRpc on a client)

    And inb4 someone states "use HLAPI," I made my own layer as I found the HLAPI a pain to work with. (the exception being Command/ClientRpc calls, once I figured out how those worked, they're easy to use) I simply need this last part solved, and I can finally start on getting my game mechanics synced.
     
  2. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    If you only use NetworkTransport then you probably shouldn't use the HLAPI stuff like Commands.
    HLAPI checks if the server is running before executing the Command code - this is just a guess but probably via NetworkServer.active or something like that. If you don't use NetworkServer (from HLAPI) then it won't be active.

    So you should probably create your own Commands, like [MyCommand]
     
  3. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Welp... in that case, I'll probably find a way of extending my existing serialization layer for RPCs then. Thank you.