private IEnumerator HuntCoroutine(Alive target) { Transform attackableSpot; if (huntRandomAttackSpot) { attackableSpot = target.GetRandomAttackableSpot(); } else { attackableSpot = target.GetClosestAttackableSpot(myTr.position); } //while ( hunting && !IsCloseEnough(attackableSpot.position + personalOffset) ) { while (hunting && (target != null) && !IsCloseToFight(target.transform.position)) { WalkTo(attackableSpot.position + personalOffset); yield return(new WaitForSeconds(.5f)); } StopWalk(); if (hunting) { SendMessage("OnHuntDone", target, SendMessageOptions.DontRequireReceiver); hunting = false; } }
private IEnumerator HuntCoroutine(Alive target) { Transform attackableSpot; if (huntRandomAttackSpot) { attackableSpot = target.GetRandomAttackableSpot(); } else { attackableSpot = target.GetClosestAttackableSpot(myTr.position); } //while ( hunting && !IsCloseEnough(attackableSpot.position + personalOffset) ) { while ( hunting && (target != null) && !IsCloseToFight(target.transform.position) ) { WalkTo( attackableSpot.position + personalOffset ); yield return new WaitForSeconds(.5f); } StopWalk(); if (hunting) { SendMessage("OnHuntDone", target, SendMessageOptions.DontRequireReceiver); hunting = false; } }