void Update() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, interactDistance, layerMask)) { interactImage.gameObject.SetActive(true); if (Input.GetKeyDown(KeyCode.E)) { if (hit.collider.tag == "Battery") { if (flashLight.Charge(1.5f)) { Destroy(hit.collider.gameObject); } else { return; } } else if (hit.collider.tag == "Key") { var key = hit.collider.GetComponent <Key>(); key.PickUp(); player.AddKey(); if (player.GetKeys() == maxKeyAmount) { Application.Quit(); Debug.Log("GAMEOVER"); gameoverMenu.InitWin(); } } } } else { interactImage.gameObject.SetActive(false); } }