private void attack() { if (_target == null) { attackReturn(null); _lerpMovement.ClearCallbacks(); return; } _lerpMovement.MovementSpeed = _attackSpeed; _lerpMovement.ClearCallbacks(); _lerpMovement.AddCallback(attackReturn); Vector2 targetPosition = _target.position; float distance = Vector2.Distance(targetPosition, _homePosition); if (distance < this.MinAttackDistance) { float angle = Mathf.Atan2((targetPosition.y - _homePosition.y), (targetPosition.x - _homePosition.x)); targetPosition.x = _homePosition.x + this.MinAttackDistance * Mathf.Cos(angle); targetPosition.y = _homePosition.y + this.MinAttackDistance * Mathf.Sin(angle); } _lerpMovement.BeginMovement(targetPosition); }
private void exitRotation() { _lerpMovement.ClearCallbacks(); _rotation.IsRotating = false; _rotation.ResetRotation(true); }