void FixedUpdate() { if (!dead) { if (_direction.magnitude > 2) { ZombieMoving(true); } else { ZombieMoving(false); } _distance = Vector3.Distance(_player.transform.position, this.transform.position); if (_distance > 15f) { followingPlayer = false; WalkRandom(); _enemyMovement.Rotation(_direction); } else if (_distance > 2.25f) { _direction = _player.transform.position - transform.position; _enemyMovement.SetDirection(_direction); followingPlayer = true; _enemyMovement.Rotation(_direction); _enemyMovement.Movement(speed); GetComponent <Animator>().SetBool("Attacking", false); } else { GetComponent <Animator>().SetBool("Attacking", true); _enemyMovement.Rotation(_direction); } } }
void Update() { if (!dead) { _agent.SetDestination(_player.position); if (_agent.velocity.magnitude > 0.5f) { BossMoving(true); } else { BossMoving(false); } if (_agent.hasPath) // i need to have a path to calculate if i'm actually on range { bool attackDistance = _agent.remainingDistance <= _agent.stoppingDistance; if (attackDistance) { BossAttack(true); Vector3 direcao = _player.position - this.transform.position; _bossMovement.Rotation(direcao); } else { BossAttack(false); } } } }