Esempio n. 1
0
        public override void Execute()
        {
            if (_canFollow)
            {
                _agent.speed = speed;
                _movement.GoTo(_player.transform.position);
                if (!_isOnMelee && !_isRangeAttacking && Vector3.Distance(_player.transform.position, transform.position) < rangeHitDistance)
                {
                    //_movement.GoTo(transform.position);
                    //transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.LookRotation(_player.transform.position - transform.position, transform.up), 2f);

                    if (_nextRangeAttack < Time.timeSinceLevelLoad)
                    {
                        AttackRange();
                        _rotateToPlayer = true;
                    }
                }
                else if (!_isOnMelee && Vector3.Distance(_player.transform.position, transform.position) < 3f)
                {
                    _isOnMelee = true;
                }

                else if (_isRangeAttacking)
                {
                    _movement.GoTo(transform.position);
                }
            }
        }
Esempio n. 2
0
        public override void Execute()
        {
            _spotted = true;

            if (_canFollow)
            {
                _agent.speed = speed;
                _movement.GoTo(_player.transform.position);
            }
        }
Esempio n. 3
0
        private void RandomizeTarget()
        {
            if (roamBounds != null)
            {
                float x;
                float z;
                while (true)
                {
                    x      = Random.Range(roamBounds[0].x, roamBounds[1].x);
                    z      = Random.Range(roamBounds[0].y, roamBounds[1].y);
                    target = new Vector3(x, transform.position.y, z);

                    NavMeshHit hit;
                    if (!NavMesh.Raycast(transform.position, target, out hit, NavMesh.AllAreas))
                    {
                        break;
                    }
                }

                movement.GoTo(target);
            }
        }