public void Awake() { if (!target) return; // obtain entity state data entityState = target.GetComponent<EntityStateData>(); // Obtain entity state if (!entityState) Debug.LogError("No EntitySataeData has been assigned to " + target.name); // obtain transform of this entity eTransform = this.transform; noiseDetectionCtrl = GameObject.FindGameObjectWithTag("Player").GetComponent<NoiseLevelCtrl>(); curPlayerStatus = PlayerStatus.Undetected; if (target == null) { if (EditorUtility.DisplayDialog("FOV_Ctrl: Detection Target not assigned!", "Assign the object with tag 'Player' by default?", "Assign", "Cancel")) { target = GameObject.FindGameObjectWithTag("Player"); } else { // target not assigned } } else // assign target Transform tTransform = target.transform; }
void Start() { // obtain targetState if (!targetState) Debug.LogError("No EntitySataeData has been assigned to " + gameObject.name); noiseDetectionCtrl = GameObject.FindGameObjectWithTag("Player").GetComponent<NoiseLevelCtrl>(); fovCtrl = gameObject.GetComponent<FOV_Ctrl>(); if (fovCtrl.target != null) { target = fovCtrl.target; } // Detection Orb init --------------------------------------------------------- // displays detection indicator gizmo above player's head when scene is playing detectionOrb = target.transform.FindChild("DetectionIndicator").gameObject; detectionOrbMat = Resources.Load("Materials/Undetected", typeof(Material)) as Material; detectionOrb.renderer.material = detectionOrbMat; detectionOrb.SetActive(fovCtrl.showGizmos); }