This section covers how to send events over the network from a specific NetworkObject.


First, you need to create a unique identifier for this event, this identifier shall be a positive integer number.



       const int LOCAL_CUSTOM_EVENT = 20000;        




 Note: Is highly recommenced to group events to avoid two events using the same code.



Local events work exactly as Global Events, the main difference is that Object Event is sent having a NetworkObject as origin and will arrive on the same object in the client instance, this means that Object Event is a smart way to update or change a specific NetworkObject.


This code illustrates how to send an event from an object over the network, you can include data on the message to be received on the target destination.



       using (DataStream writer = new DataStream()) {
             writer.Write(this.transform.position); // Vector3
               writer.Write(this.objectStatus); // int
               writer.Write(this.errorCode); // uint

      // Send event

       // Is important to send using "this" because system will include object information's during event send
             this.Send(LOCAL_CUSTOM_EVENT, writer, DeliveryMode.Reliable);
       }