// Update is called once per frame
    void Update()
    {
        this.gameObject.UpdateSortingOrder ();

        if (this.gameObject.transform.position != endMarker && ( IsMoving && animator.GetCurrentAnimatorStateInfo(0).IsName("Running"))) {
            if(startFlag) {
                startFlag = false;
                startTime = Time.time;
            }

            //start time is current bug
            float distCovered = (Time.time - startTime) * speed;
            float fracJourney = distCovered / journeyLength;

            if (fracJourney > 1) {
                arrived = true;
                IsMoving = false;

                if (postStep != null) {
                    postStep ();
                    postStep = null;
                }
            }

            transform.position = Vector3.Lerp (startMarker, endMarker, fracJourney);
        } else if(arrived && target != null && !animator.GetCurrentAnimatorStateInfo(0).IsName("Running")) {
            PublicAttack();
        }
    }
    public void ReturnToPreviousLocation()
    {
        IsMoving = true;
        this.target = null;
        arrived = false;
        startFlag = true;
        endMarker = prevLoc;
        startMarker = this.gameObject.transform.position;
        journeyLength = Vector3.Distance(startMarker, endMarker);
        this.transform.localScale = new Vector3 (this.transform.localScale.x * -1, this.transform.localScale.y, this.transform.localScale.z);

        //Anonymous delegate specific to the returning from previous location
        //We want to flip the object back around.
        postStep = delegate() {
            this.transform.localScale = new Vector3 (this.transform.localScale.x * -1, this.transform.localScale.y, this.transform.localScale.z);
        };
    }