IEnumerator Glitch() { if (enabled) { yield return(new WaitForSeconds(onTime)); StartCoroutine(forceField.SwitchState()); yield return(new WaitForSeconds(offTime)); StartCoroutine(forceField.SwitchState()); StartCoroutine(Glitch()); } }
void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player" || other.gameObject.tag == "Obstacle") { StartCoroutine(forceField.SwitchState()); anim.Play("ButtonPushed"); } }