Search Unity

Custom Messages - why don't they work on Host like RPC do?

Discussion in 'Netcode for GameObjects' started by qNaN, Aug 13, 2022.

  1. qNaN

    qNaN

    Joined:
    Dec 29, 2015
    Posts:
    26
    I am working on an implementation, where I can have Remote Procedure Calls independently of NetworkObjects. I would like a system, where I can call it even from regular objects that otherwise have nothing to do with the network system.
    I am really surprised that something like that isn't possible already natively in Netcode.

    Anyway, I have been testing the different possibilities, and was quite happy when I saw, that Custom Messages indeed did what I wanted - only to be sorely disappointed when I tested it on a Host. A Host will not - unlike RPC - send a message to its client-part. I looked up and found that someone had reported it as a bug, but he got the reply, that it was like that "by design", because the messages were supposed to be between clients? Umm, what? Why? Why couldn't they work exactly like RPC, just being independent of NetworkObjects? Why this wierd limitation ONLY for Host? It simply doesn't make sense in my book. And what is this reason that the messages are supposed to be between clients? Why can't a programmer decide himself what he wants to use it for?

    Now I will be forced to spawn a NetworkObject through which I can route all my independent RPCs, but I find it a poor solution to have an object exist only for that, when it is completely unnecessary. Also, RPCs will fire only every tick, a limitation Custom Messages do not have, so there is that as well.

    Unity should give us NetworkObject-independent RPCs, and Custom Messages should work properly also on Host.

    This is the bug report I refer to, the reason is given as:
    "TwoTenPvP:
    This behaviour is by design. Unlike RPC's they do not invoke through message buffers. Custom messages are simply to communicate between different clients."
    https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/issues/342
     
    Last edited: Aug 13, 2022
  2. qNaN

    qNaN

    Joined:
    Dec 29, 2015
    Posts:
    26
    Please ignore, my thread is too ignorant, which has become obvious to me as I learn more.
     
  3. three10

    three10

    Joined:
    Jan 3, 2014
    Posts:
    23
    Just learned about this as well. But not from the official documentation (which I must have read about 10 times already) but from this post after 2 days of work starting to migrate from UNet to Netcode. This is super frustrating! In our project we basically only use custom network messages which are sent between server and clients. Since for now a host was basically a server+client we could run server+clients and host+clients and the code was the same for all clients no matter what. Now when starting as a host I cannot even register the same network message for the server and client part or exchange messages between them. Adding all that code just for the one special case that the client is part of a host is not feasible for our existing project. That Netcode has no mechanism to handle this anymore is just frustrating. Now we have to try out different libraries that don't have this restriction to find a suitable replacement for UNet. This should at least be in the migration documentation/breaking changes! It only says:
    Client and Server have separate representations in UNet. UNet has a number of callbacks that do not exist for Netcode.

    which doesn't really tell you that.