void OnTriggerEnter(Collider other) { source.clip = open; source.Play(); // get the receiver objects GameObject [] receivers = GameObject.FindGameObjectsWithTag("DFAAgent"); // for each receiver object foreach (GameObject obj in receivers) { // Get the script AgentReceiver r = (AgentReceiver)obj.GetComponent(typeof(AgentReceiver)); // call the receiver post method r.postMessage("0"); } }
void OnTriggerExit(Collider other) { enemyPathfinder.GetComponent <pathAgentScript>().pathTrigger = true; source.clip = closed; source.Play(); // get the receiver objects GameObject[] receivers = GameObject.FindGameObjectsWithTag("DFAAgent"); // for each receiver object foreach (GameObject obj in receivers) { // Get the script AgentReceiver r = (AgentReceiver)obj.GetComponent(typeof(AgentReceiver)); // call the receiver post method r.postMessage("0"); } }
void OnTriggerEnter(Collider other) { if (!triggered) { enemyPathfinder.GetComponent <pathAgentScript>().pathTrigger = true; // get the receiver objects GameObject[] receivers = GameObject.FindGameObjectsWithTag("DFAAgent"); // for each receiver object foreach (GameObject obj in receivers) { // Get the script AgentReceiver r = (AgentReceiver)obj.GetComponent(typeof(AgentReceiver)); // call the receiver post method triggered = true; r.postMessage("3"); } } }
void OnTriggerEnter(Collider other) { if (!triggered) { AudioSource source = GetComponent <AudioSource>(); source.clip = explosion; source.Play(); // get the receiver objects GameObject[] receivers = GameObject.FindGameObjectsWithTag("DFAAgent"); // for each receiver object foreach (GameObject obj in receivers) { // Get the script AgentReceiver r = (AgentReceiver)obj.GetComponent(typeof(AgentReceiver)); // call the receiver post method triggered = true; r.postMessage("4"); } } }