Search Unity

Better way to send commands with change checking

Discussion in 'Multiplayer' started by pojoih, Jul 17, 2015.

  1. pojoih

    pojoih

    Joined:
    Mar 30, 2013
    Posts:
    226
    My Update loop is flooded with stuff like this:

    Code (CSharp):
    1. if (isFireingMissile != isFireingMissileChanged) {
    2.                         CmdSyncIsFireingMissiles(isFireingMissile);
    3.                         isFireingMissileChanged = isFireingMissile;
    4.                     }
    So for every bool I want to send to the server I have to make two bools and check for change. Maybe I'm overseeing something in the docs, but Is there a better way to prevent commands from being send when nothing has changed? I know Syncvar is doing this automaticly but from the profile I see that the command is executed, regardless of a change in their parameters