private void UpdataRoute()
    {
        if (RouteRangeCheck() && nextPoint.Equals(unit.destination))
        {
            arrive         = true;
            rigid.velocity = Vector2.zero;
        }
        else
        {
            arrive = false;
        }

        if (arrive)
        {
            return;
        }

        if (!oldValue.Equals(unit.destination))
        {
            nextPoint = PetUtility.FindNextWayPoint(unit.transform.position, unit.destination);
            oldValue.Set(unit.destination.x, unit.destination.y);
        }

        DoorCheck();
        if (nearDoor)
        {
            nextPoint = PetUtility.FindNextWayPoint(unit.transform.position, unit.destination);
            //Debug.Log(nextPoint);
        }
        nextPoint = PetUtility.FindNextWayPoint(unit.transform.position, unit.destination);

        //control the patroling of the unit
        if (nearDoor && RouteRangeCheck())
        {
            //Debug.Log("try go next floor");
            rigid.velocity = Vector2.zero;
            enterDoor      = true;
            unit.enterDoor = true;
            return;
        }
        else if (RouteRangeCheck())
        {
            nextPoint = PetUtility.FindNextWayPoint(unit.transform.position, unit.destination);
        }

        if (!enterDoor)
        {
            if (nextPoint.x > transform.position.x)
            {
                rigid.velocity = Vector2.right * unit.velocity;
                //todo:maybe the flip could be done by unitbehaviour
                transform.rotation = Quaternion.Euler(0, 0, 0);
            }
            else
            {
                rigid.velocity     = Vector2.left * unit.velocity;
                transform.rotation = Quaternion.Euler(0, 180, 0);
            }
        }
    }
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     transform = animator.transform;
     rigid     = transform.GetComponent <Rigidbody2D>();
     unit      = animator.GetComponent <UnitBehaviour>();
     nextPoint = PetUtility.FindNextWayPoint(unit.transform.position, unit.destination);
     enterDoor = false; unit.enterDoor = false;
     UpdataRoute();
 }