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); } } }
public override void Execute() { _spotted = true; if (_canFollow) { _agent.speed = speed; _movement.GoTo(_player.transform.position); } }
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); } }