public override void MoveEnemyTowardsTarget(Transform Target) { if (EnemyCurrentState == EnemyState.walk || EnemyCurrentState == EnemyState.idle && EnemyCurrentState != EnemyState.stagger) { Vector3 DirectionTotarget = Vector3.MoveTowards(transform.position, Target.position, MoveSpeed * Time.deltaTime); UpdateEnemyAnimation(DirectionTotarget - transform.position); EnemyRigidbody.MovePosition(DirectionTotarget); ChangeEnemyStateTo(EnemyState.walk); EnemyAnimator.SetBool("Moving", true); } }
private void ReturnToPatrolling() { if (Vector3.Distance(transform.position, Path[CurrentPoint].position) > RoundingDistance) { // the current path is available .. Vector3 DirectionToGoal = Vector3.MoveTowards(transform.position, Path[CurrentPoint].position, MoveSpeed * Time.deltaTime); // returne to the patrol path .. UpdateEnemyAnimation(DirectionToGoal - transform.position); EnemyRigidbody.MovePosition(DirectionToGoal); } else { // update patrol path .. if (CurrentPoint == Path.Length - 1) { CurrentPoint = 0; CurrentGoal = Path[0]; } else { CurrentPoint++; CurrentGoal = Path[CurrentPoint]; } } }