void Update() { if (SoundReceiver.getAlarm()) { foreach (GameObject security in securityGuards) { security.GetComponent <Animator>().SetBool("alarma", true); } } }
private void OnTriggerExit(Collider coll) { SoundReceiver receiver = coll.gameObject.GetComponent <SoundReceiver>(); if (receiver == null) { return; } int objId = coll.gameObject.GetInstanceID(); receiverDictionary.Remove(objId); }
private void OnTriggerStay(Collider other) { string tag = other.gameObject.tag; GameObject target = other.gameObject; Vector3 agentPos = agent.transform.position; Vector3 targetPos = target.transform.position; Vector3 direction = targetPos - agentPos; float lenght = direction.magnitude; direction.Normalize(); if (debugMode) { Debug.DrawLine(agentPos, targetPos, Color.red); } /*Lanzamos un raycast que se detiene cuando impacta con algo*/ RaycastHit hit; if (Physics.Raycast(agentPos, direction, out hit)) { if (debugMode) { Debug.Log("Raycast" + hit.collider.gameObject.tag); } if (hit.collider.gameObject.tag.Equals("Agent Garcia")) { animator.SetBool("alarma", false); SoundReceiver.setAlarm(false); animator.SetBool("esperando", false); animator.SetBool("viendoJugador", true); animator.SetTrigger("aPerseguir"); } } }