void OnTriggerExit(Collider other) { WirelessTransmitter wirelessTransmitter = other.GetComponent <WirelessTransmitter>(); if (wirelessTransmitter != null && wirelessTransmitter.receiverIds.Contains(id)) { currentlyReceivingTransmitters.Remove(wirelessTransmitter); if (currentlyReceivingTransmitters.Count == 0) { foreach (MonoBehaviour triggerable in triggerables) { triggerable.enabled = false; } } } }
void OnTriggerEnter(Collider other) { WirelessTransmitter wirelessTransmitter = other.GetComponent <WirelessTransmitter>(); if (wirelessTransmitter != null && wirelessTransmitter.receiverIds.Contains(id)) { RaycastHit hit; Vector3 rayStart = wirelessTransmitter.collider.ClosestPoint(trs.position); Vector3 rayEnd = trs.position; rayStart += (rayEnd - rayStart).normalized * Physics.defaultContactOffset; Vector3 rayVector = rayEnd - rayStart; if (Physics.Raycast(rayStart, rayVector, out hit, rangeSphereCollider.bounds.extents.x, whatBlocksTransmission) && hit.collider.gameObject == gameObject) { currentlyReceivingTransmitters.Add(wirelessTransmitter); foreach (MonoBehaviour triggerable in triggerables) { triggerable.enabled = true; } } } }