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(); } } } }
ConduitControl control; // Activates other objects when the circuit is complete void Awake() { conductingObj = null; control = gameObject.GetComponent <ConduitControl>(); }