// Update is called once per frame void Update() { if (Input.GetButtonDown(inputName)) { Ray clickRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit raycast; if (Physics.Raycast(clickRay, out raycast, Mathf.Infinity)) { tempInteractable = raycast.collider.gameObject.GetComponent <Interactable>(); if (tempInteractable.Equals(null)) { //Do nothing } else { tempInteractable.ChangeActive(); } } } }