// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { OpenDoor door = hit.collider.GetComponentInParent <OpenDoor>(); if (door) { door.Animate(); } } } }