Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        /// <inheritdoc />
        protected override Behavior.Status UpdateInternal()
        {
            //Ensure target.
            if (!Targeter.HasTarget)
            {
                return(BehaviorTree.Behavior.Status.Failure);
            }

            //Get the direction.
            Vector2 directionToTarget = Targeter.DirectionToTarget();

            //Calculate the perpendicular vector to the direction.
            Vector2 perpendicular = Clockwise
                ? directionToTarget.PerpendicularCW()
                : directionToTarget.PerpendicularCCW();

            //Move.
            MovementController.ApplyMovement(perpendicular);
            return(BehaviorTree.Behavior.Status.Running);
        }
Esempio n. 3
0
        /// <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);
        }