private void ProcessBotCommands() { if (socket == null) { return; } if (!socket.IsConnected()) { Destroy(gameObject); } foreach (var command in socket.ReceiveCommands()) { lastBotCommandTime = Time.time; //Debug.Log("Processing " + JsonUtility.ToJson(command)); if (command.action == "forward") { brake = 0; forward = command.value; } else if (command.action == "reverse") { brake = 0; forward = 0; } else if (command.action == "brake") { forward = 0; brake = command.value; } else if (command.action == "turn") { targetAngle = -command.value; // bot uses -1 right, +1 left } } }