/// <summary>Sends data to the client via UDP.</summary> /// <param name="packet">The packet to send.</param> public void SendData(Packet packet) { try { packet.InsertInt(instance.myId); // Insert the client's ID at the start of the packet if (socket != null) { socket.BeginSend(packet.ToArray(), packet.Length(), null, null); } } catch (Exception ex) { Debug.Log($"Error sending data to server via UDP: {ex}"); } }