public override void LogicalUpdate()
        {
            MoveComponent move      = _attackMode.AICharacter.MoveComponent;
            Vector3       targetPos = _attackMode.Target.Position;

            _attackMode.Currentattack.Activate(true);
            float distSq  = (targetPos - move.Position).sqrMagnitude;
            float ReachSq = _attackMode.Currentattack.Reach.Sq();

            if (distSq < ReachSq * _attackMode.ratioStartAttacksq / 4f)
            {
                move.SetBaseSpeed();
            }
            else
            {
                move.SetRatioToBaseSpeed(1.6f);
            }
            if (distSq > ReachSq * _attackMode.ratioOutsq)
            {
                _SM.ChangeState(_outOfARState);
            }
            else if (distSq > ReachSq * _attackMode.ratioStopMovingsq)
            {
                if (!move.HasPath || (targetPos - _attackMode._semiLastTargetPos).sqrMagnitude > move.CurrentSpeed.Sq())
                {
                    _attackMode._semiLastTargetPos = targetPos;
                    move.StartFromScratchNewEndpos(targetPos);
                }
            }
            else
            {
                _SM.ChangeState(_withinARNoMoveState);
            }
        }
コード例 #2
0
 private void IfSprint()
 {
     if (SprintMultiplier != 1f && _inputsSO.InputSprint.CheckInput())
     {
         _moveComponent.SetRatioToBaseSpeed(SprintMultiplier);
         _sprintedLastFrame = true;
     }
     else
     {
         if (_sprintedLastFrame)
         {
             _moveComponent.SetBaseSpeed();
         }
         _sprintedLastFrame = false;
     }
 }
コード例 #3
0
        public sealed override void LogicalUpdate()
        {
            MoveComponent move = _evadeMode.AICharacter.MoveComponent;
            Vector3       pos_sub_targetNormed = (move.Position - _evadeMode.TargetToFleeFrom.Position).normalized;

            if (!move.HasPath)
            {
                _evadeMode.Safeplace = _evadeMode.TargetToFleeFrom.Position + _evadeMode.SafeDistanceFromFleeTarget * pos_sub_targetNormed;
                move.StartFromScratchNewEndpos(_evadeMode.Safeplace);
                move.SetBaseSpeed();
            }
            if ((_evadeMode.TargetToFleeFrom.Position - move.Position).sqrMagnitude < _evadeMode.SafeDistanceFromFleeTarget.Sq() * (0.2f * 0.2f))
            {
                _SM.ChangeState(_wayTooCloseState);
            }
            else if ((_evadeMode.TargetToFleeFrom.Position - move.Position).sqrMagnitude > _evadeMode.SafeDistanceFromFleeTarget.Sq())
            {
                _SM.ChangeState(_inSafeDistanceState);
            }
        }