public void OnPathComplete(Path p)
 {
     if (!p.error) {
         path = p;
         // Reset the waypoint counter
         currentWaypoint = 0;
         // Reset the order
         RTSUnitOrder.OrderStruct order = new RTSUnitOrder.OrderStruct(RTSUnitOrder.Order.Stop, gameObject.transform.localPosition);
         gameObject.SendMessage("IssueOrder", order);
     }
 }
    void Update()
    {
        // On Right Click
        if (Input.GetMouseButtonUp(1)) {
            // Get the mouse click point
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit info;
            Physics.Raycast(ray, out info, Mathf.Infinity, 1);

            // For every unit that is selected, issue the order to move to that position
            foreach (GameObject unit in UnitManager.GetSelectedObjects()) {
                RTSUnitOrder.OrderStruct order = new RTSUnitOrder.OrderStruct(RTSUnitOrder.Order.Move, info.point);
                unit.SendMessage("IssueOrder", order);
            }
        }
    }
    void Update()
    {
        // On Right Click
        if (Input.GetMouseButtonUp(1)) {
            // Raycast from the Camera.main to the ground to find the mouse click point on the ground
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit info;
            Physics.Raycast(ray, out info, Mathf.Infinity, Ground);

            Debug.Log(info.point);
            // For every unit that is selected, issue the order to move to that position
            foreach (GameObject unit in UnitManager.GetSelectedObjects()) {
                RTSUnitOrder.OrderStruct order = new RTSUnitOrder.OrderStruct(RTSUnitOrder.Order.Stop, new Vector3(0, 0, 0));
                if (unit.GetComponent<RTSUnitMovement>() != null) {
                    order = new RTSUnitOrder.OrderStruct(RTSUnitOrder.Order.Move, info.point);
                } else if (unit.GetComponent<RTSShipMovement>() != null) {
                    order = new RTSUnitOrder.OrderStruct(RTSUnitOrder.Order.Face, info.point);
                }
                unit.SendMessage("IssueOrder", order);
            }
        }
    }