private void updateMotors() { string json = udpreceiver.getLatestUDPPacket((int)UDPReceive.MessageType.MOTORS); if (json.Length < 10) { return; } int startIndex = json.IndexOf("{") + 1; json = json.Substring(startIndex + 1, json.Length - 2 - startIndex); string[] motorArray = json.Split('m'); for (int i = 0; i < motorArray.Length; i++) { int index = motorArray[i].IndexOf("{"); motorArray[i] = motorArray[i].Substring(index, motorArray[i].Length - index); SerializedSCS15 scs15 = JsonUtility.FromJson <SerializedSCS15>(motorArray[i]); int id = scs15.i - 2; float pos = sens[id] * 100.0f * ((float)(scs15.p) - offset[id] - 512.0f) / 512.0f; motorController.SetPosition(id, pos); } }