/// <inheritdoc /> protected override Behavior.Status UpdateInternal() { //Check if we're far enough. float distance = Targeter.DistanceToTarget(); if (distance > _farEnoughDistance) { return(BehaviorTree.Behavior.Status.Success); } //Move away. Vector2 directionToTarget = Targeter.DirectionToTarget(); MovementController.ApplyMovement(-directionToTarget); return(BehaviorTree.Behavior.Status.Running); }
/// <inheritdoc /> protected override Behavior.Status UpdateInternal() { //Lost target. if (!Targeter.HasTarget) { return(BehaviorTree.Behavior.Status.Failure); } //Check if close enough. float distance = Targeter.DistanceToTarget(); if (distance < _targetReachedDistance) { return(BehaviorTree.Behavior.Status.Success); } //Move towards target. Vector3 direction = Targeter.DirectionToTarget(); MovementController.ApplyMovement(direction); return(BehaviorTree.Behavior.Status.Running); }