Exemple #1
0
    private void HandleMovement()
    {
        if (_pathVectorList != null && _currentPathIndex < _pathVectorList.Count)
        {
            Vector3 targetPosition = _pathVectorList[_currentPathIndex];
            if (_enemyShooting != null)
            {
                _enemyShooting.LookAtPosition(targetPosition);
            }

            if (Vector3.Distance(transform.position, targetPosition) > 1f)
            {
                Vector3 moveDir = (targetPosition - transform.position).normalized;

                float distanceBefore = Vector3.Distance(transform.position, targetPosition);
                transform.position = transform.position + moveDir * _currentSpeed * Time.deltaTime;
            }
            else
            {
                _currentPathIndex++;
                if (_currentPathIndex >= _pathVectorList.Count)
                {
                    StopMoving();
                }
            }
        }
    }