void OnTriggerEnter(Collider otherobj) { if (otherobj.gameObject.CompareTag("Glasszone")) { Debug.Log("Hit from glasses"); } else { if (buttonPressed == false) { if (!YAxis) { transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y, transform.localPosition.z - 0.009f); Debug.Log("button" + buttonNum); other.SafeLogic(buttonNum, opensBookShelf); buttonPressed = true; gameObject.GetComponent <Renderer>().material.EnableKeyword("_EMISSION"); } else if (YAxis) { transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y - 0.009f, transform.localPosition.z); Debug.Log("button" + buttonNum); other.SafeLogic(buttonNum, opensBookShelf); buttonPressed = true; } StartCoroutine(ButtonDelay()); } } if (opensBookShelf == true && hasntPlayedYet == false) { hasntPlayedYet = true; ScriptA.RetractBookShelf(); } }