Search Unity

Third Party [SOLVED] Mirror - Syncvar hooks not being called when running from server build

Discussion in 'Multiplayer' started by Bob_Hamburger, Nov 15, 2020.

  1. Bob_Hamburger

    Bob_Hamburger

    Joined:
    Nov 15, 2020
    Posts:
    2
    Hello everyone, my teammates and I are developing a multiplayer game and we decided to opt for the Mirror library.
    As for now everything seems working when running a configuration with one client hosting the game and the other joining.
    However, we need to run a configuration with one server hosting the game and two clients joining.
    While when running in the first option everything works fine, in the latter all the syncvars hooks seems to not being fired.
    Am I missing something when switching configuration? Is there some kind of option/variable to be set when running a server build?
     
  2. Bob_Hamburger

    Bob_Hamburger

    Joined:
    Nov 15, 2020
    Posts:
    2
    As I digged more in the documentation, I discovered this:
    https://unitystation.github.io/unitystation/development/SyncVar-Best-Practices-for-Easy-Networking/

    1. SyncVar hooks don't fire on the server when the server changes the field. They only fire on the client when the client receives the new value. Thus the server player will not have the hook called. This is the reason to always change the syncvar by way of the hook method on the server.
    This solves the issue, as I was trying to fire an event inside the server when updating a synchronized variable also on the server...
     
  3. akuno

    akuno

    Joined:
    Dec 14, 2015
    Posts:
    88
    jdrandir likes this.