Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Unity Multiplayer How do you use SetDirtyBit ?

Discussion in 'Connected Games' started by Paradoks, Jul 9, 2018.

  1. Paradoks

    Paradoks

    Joined:
    Oct 13, 2009
    Posts:
    393
    Hi,

    It is a pretty newbie question, i don't really understand how to use it as the manual don't say much.
    What is this parameter "Bit mask to set" ?
    Why sometimes people put parametters sometimes not ?

    thx for you answers.
     
  2. Paradoks

    Paradoks

    Joined:
    Oct 13, 2009
    Posts:
    393
    @aabramychev
    Someone from unity at least please, you make a tool, and dont let informations on manual.
     
  3. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    532
    I'm sorry, but I don't understand what are you talking about. What SetDirtyBit do you want to set and where? :(
     
  4. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    2,396
    SetDirtyBits sets NetworkBehaviour.syncVarDirtyBits:
    upload_2018-7-21_13-13-11.png

    UNET only serializes your components if at least one of them is dirty.

    If you are wondering what this magic is for: let's say you have 3 variables in your Player script that you want to sync over the network. OnSerialize gets called, then you sync all 3 of them. OnSerialize gets called again, but maybe only 1 of them changed, so there's no point in syncing all 3 of them again, or you'd waste bandwidth. You only want to sync the changed one. So in order to know which things changed, you always also send the dirty bit mask. For example, if the first bit is 1, then your first value changed. If the second bit is 1, then your second value changed, etc.