//Now we check if there is a collision with the object private void OnCollisionEnter(Collision collision) { //If there is, we check if it's either the Box or the Capsule that has touched it. We also need to know if it was already touched before. if ((collision.collider.CompareTag("Box") || collision.collider.CompareTag("Capsule")) && !hasTriggered) { //If it's the Box or the Capsule, we make the button move a bit and make sure we know it has been triggered hasTriggered = true; transform.DOPunchScale(new Vector3(0.5f, 0f, 0.5f), 1f); //Depending on if their Box Collider Component is enabled or not, we either fade in or fade out the doors if (door.GetComponent <BoxCollider>().enabled) { doorScript.FadeOut(); } else { doorScript.FadeIn(); } if (door1.GetComponent <BoxCollider>().enabled) { doorScript1.FadeOut(); } else { doorScript1.FadeIn(); } } }