示例#1
0
        // Update is called once per frame
        void Update()
        {
            if (_health.IsDead() || Player.transform == null)
            {
                return;
            }
            var target = Player.transform.position;

            _agent.SetDestination(target);

            // Handle jumps here?
            if (_agent.remainingDistance >= _agent.stoppingDistance && !_attacking)
            {
                _agent.Resume();
                _character.Move(_agent.desiredVelocity, false);
                _character.SetAttacking(false);
            }
            else
            {
                _agent.Stop();
                _character.Move(Vector3.zero, false);

                HandleAttack();
                UpdateRotation();
            }

            if (!GetComponent <Animator>().GetCurrentAnimatorStateInfo(0).IsName("Base.Attacking"))
            {
                _attacking = false;
            }
        }
示例#2
0
        void Update()
        {
            if (_health.IsDead() || Player.transform == null)
            {
                return;
            }
            Agent.SetDestination(Player.transform.position);

            if (!PlayerInRange())
            {
                Agent.Resume();
                Attack.AllowAttack(false);
                _enemyCharacter.Move(Agent.desiredVelocity, false);
            }
            else
            {
                Agent.Stop();
                Attack.AllowAttack(true);
                _enemyCharacter.Move(Vector3.zero, false);
                UpdateRotation();
            }
        }