private void Pulse() { //Pulse can only be activated when the vitality is sufficient. Otherwise, play a "cannot do this" sound. if (vitality > threshold && Vector3.Distance(player.transform.position, transform.position) < 5f) { Instantiate(pulse, transform.position, Quaternion.identity); vitality -= pulseCost; //Search for interactables and activate them: Collider[] pulseHits = Physics.OverlapSphere(transform.position, pulseRange); for (int i = 0; i < pulseHits.Length; i++) { InteractableBase interactable = pulseHits[i].GetComponent <InteractableBase>(); if (interactable) { interactable.Activate(); } else { //Check for interactables in parents interactable = pulseHits[i].GetComponentInParent <InteractableBase>(); if (interactable) { interactable.Activate(); } else { //Last resort: check for interactables in children. interactable = pulseHits[i].GetComponentInChildren <InteractableBase>(); if (interactable) { interactable.Activate(); } } } } } else if (Vector3.Distance(player.transform.position, transform.position) < 5f) { AudioSource.PlayClipAtPoint(noPulseClip, transform.position); } }