private void OnTriggerEnter(Collider other) { // IMPORTANT : ConduitControl must be set to "Toggleable" for the box conduit to work if (control.Toggleable) { // Checks if the circuit is already complete if (conductingObj == null) { GameObject triggeredObj = other.gameObject; BaseMatter matter; // If the circuit is open, check if the incoming object is conductive if (triggeredObj.TryGetComponent(out matter) && matter.IsConductive) { // If the incoming object is conductive, add it to the circuitt and turn on the objects in the ConduitControl script control.TurnOn(); conductingObj = triggeredObj; } } } else { Debug.LogWarning("Conduit Controls attached to Box Conduits must be set to Toggleable in order to function"); } }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.CompareTag("Conduit")) // Look for a conduit tag { ConduitControl condControl = collision.gameObject.GetComponent <ConduitControl>(); if (!condControl.Toggleable) { condControl.TurnOn(); // Turn on the conduit } else { if (condControl.ConduitEnabled) { condControl.TurnOff(); } else { condControl.TurnOn(); } } } }