void OnTriggerExit(Collider other) { doorAnim comp = doorControl.GetComponent <doorAnim>(); comp.Close(); // Execute the open routine. }
// This is where we send trigger messages to other script components. // It makes more sense to do it this way than to use a ton of code in // the trigger events to animate the doors. void OnTriggerEnter(Collider other) { // Typical Unity trick here: go fetch the animation script of the // doorControl object we set up earlier and execute a function. doorAnim comp = doorControl.GetComponent <doorAnim>(); comp.Open(); // Execute the open routine. }