using System.Collections; using System.Collections.Generic; using UnityEngine; using SWS; using UnityEngine.AI; public class detector : MonoBehaviour { public Material Cone_material, Cone_Alert; public GameObject cone, cone1, cone2; public GameObject Police; AudioSource source; // Start is called before the first frame update void Start() { source = GameObject.Find("Audio").GetComponent(); cone.GetComponent().material = Cone_material; cone1.GetComponent().material = Cone_material; cone2.GetComponent().material = Cone_material; } // Update is called once per frame void Update() { } public void OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("body")) { cone.GetComponent().material = Cone_Alert; cone1.GetComponent().material = Cone_Alert; cone2.GetComponent().material = Cone_Alert; Police.GetComponent().enabled = true; // Police.GetComponent().enabled = true; Police.GetComponent().angry = true; Police.GetComponent().enabled = true; Police.GetComponent().Pause(); if (!source.isPlaying) { source.Play(); } } } }