ObjectNet allows to execute script methods over network, this can be a powerful mechanism to keep you game synchronized and handle with aspects of your multiplayer game.


The network method can be executed mainly in three ways.



// You class must have a method        

void MethodName() {

  ... Do something

}


// And in any part of you code at same class you can have

this.NetworkExecute(this.MethodName);

     


ObjectNet will decide the best place to execute you code, if code will be executed on server, on client or in both.



You can also select if your method shall be executed on server only.



// Execute method on server only

this.NetworkExecuteOnServer(this.MethodName);



Finally you can select if your method shall be executed on client's.



// Execute method on all clients ( including me if I'm a client )

this.NetworkExecuteOnClient(this.MethodName);



ObjectNet also allow to execute methods with parameters if needed



         // You class must have a method        

void MethodName(int life, string name) {

   // Do something

}


// And in any part of you code at same class you can have

this.NetworkExecute<Int32, String>(this.MethodName, 10, "MyName");


     


Note: You can execute methods with up to 10 arguments.