public void hitSwitch() { if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Switch")) { animator.Play("Switch"); } doorScript.switches(); switchobj.enabled = false; }