Search Unity

Feedback Be Careful with Pre-processor defined NetworkVariables

Discussion in 'Multiplayer' started by KingKRoecks, May 28, 2022.

  1. KingKRoecks

    KingKRoecks

    Joined:
    Jul 28, 2013
    Posts:
    155
    upload_2022-5-27_18-22-11.png

    In this example code from the BossRoom sample, they have a NetworkVariable that is only there for the Editor, or if the DEVELOPMENT_BUILD flag is set (by checking that box on Build menu, presumably).

    The pitfall associated with this, is if you ever have an Editor connecting with a built player without the "DEVELOPMENT_BUILD" flag, your serialization will fail because this entity existing on one and not the other creates an offset in the FastBufferReader / FastBufferWriter by the amount of bytes that it takes to serialize this.

    And that... from my last few weeks experience... is a hard F***ing bug to track down.
     
    Cranom and thethanksforthegod like this.
  2. thethanksforthegod

    thethanksforthegod

    Joined:
    Feb 18, 2020
    Posts:
    19
    thanks bro It's really so hard to figure that and that offset will break everything it's a fatal bug.
     
    KingKRoecks likes this.