private MeshRenderer _meshRenderer; // CB: The meshRenderer that renders through walls // Use this for initialization void Start() { _baseHeight = transform.position.y; _maxHeight = new Vector3(transform.position.x, _baseHeight + 0.25f, transform.position.z); _lowerHeight = new Vector3(transform.position.x, _baseHeight - 0.25f, transform.position.z); step = 0.25f * Time.deltaTime; _player = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>(); _gameInfo = GameObject.Find("GameManager").GetComponent <GameInfo>(); _mementoUtils = GameObject.Find("GameManager").GetComponent <MementoUtils>(); _meshRenderer = GetComponent <MeshRenderer>(); }
/// <summary> Initializes required components </summary> void Start() { _navAgent = GetComponent <NavMeshAgent>(); _audioSource = GetComponent <AudioSource>(); _animator = GetComponentInChildren <Animator>(); _neutralAudio = _audioSource.clip; _player = GameObject.FindGameObjectWithTag("Player"); _patrolManager = GameObject.Find("GameManager").GetComponent <PatrolManager>(); _mementoUtils = GameObject.Find("GameManager").GetComponent <MementoUtils>(); _gameInfo = GameObject.Find("GameManager").GetComponent <GameInfo>(); _timeOnEnterIdle = Time.time; _timeOnTargetPlayer = Time.time; if (PATROL_START != null) { /* Initialize patrol start point */ _navAgent.SetDestination(PATROL_START.transform.position); _patrolCurrent = PATROL_START; ChangeState(EnemyState.Patrolling); } else { Debug.Log("<color=blue>AI Warning: This AI does not have a patrol set! (" + gameObject.name + ")</color>"); } //Find and store a reference to the vision light Light[] lights = gameObject.GetComponentsInChildren <Light>(); foreach (Light light in lights) { if (light.tag == "EnemyVisionLight") { visionLight = light; } } if (visionLight != null) { visionLight.range = FOV_CONE_LENGTH; visionLight.spotAngle = FOV_CONE_RADIUS; _neutralColor = visionLight.color; } }