void Update() { // If player presses 'e' and that object is the current interactable object (in object trigger point) if (Input.GetButtonDown("Interact") && currentInterObj) { // If player has interacted with a medkit and is bleeding from the monster if (currentInterObjScript.IsMedkit() && GetComponent <Bleeding>().bleeding) { // Stops the player from bleeding, resets timer back to 120 and disables it, plays a sound and removes medkit from game GetComponent <Bleeding>().bleeding = false; GetComponent <Bleeding>().timer = 120; GetComponent <Bleeding>().Countdown.enabled = false; audioSource.PlayOneShot(heal); currentInterObj.SetActive(false); } else { //Alert player they can't use medkit } // If the item is an item that can be put in the inventory if (currentInterObjScript.inventory) { // Adds the item to the inventory, removes the item from game, plays sound, adds 1 to the counter and displays it to player. inventory.AddItem(currentInterObj); currentInterObjScript.DoInteraction(); audioSource.clip = keys; audioSource.pitch = 1.5f; audioSource.Play(); count = count + 1; SetCountText(); Debug.Log(currentInterObj.activeInHierarchy); } // uses tags to check which note in particular has been interacted with if (currentInterObj.CompareTag("Note")) { Debug.Log("inside"); // shows that specific note the player interacts with currentInterObj.GetComponent <Note>().ShowNoteImage(); } if (currentInterObj.CompareTag("otherNote")) { Debug.Log("inside"); currentInterObj.GetComponent <Note1>().ShowNoteImage(); } if (currentInterObj.CompareTag("otherNote1")) { Debug.Log("inside"); currentInterObj.GetComponent <Note2>().ShowNoteImage(); } if (currentInterObj.CompareTag("otherNote2")) { Debug.Log("inside"); currentInterObj.GetComponent <Note3>().ShowNoteImage(); } if (currentInterObj.CompareTag("otherNote3")) { Debug.Log("inside"); currentInterObj.GetComponent <Note4>().ShowNoteImage(); } // checks if the interactable object can be opened (eg. doors) if (currentInterObjScript.openable) { // checks if door is locked if (currentInterObjScript.locked) { // checks if player has a key in their inventory if (inventory.FindKey()) { // key is found in inventory: door is unlocked, plays animation, removes 1 from the counter and shows player, plays sound. currentInterObjScript.locked = false; Debug.Log(currentInterObj.name + " was unlocked"); currentInterObjScript.Open(); count = count - 1; SetCountText(); currentInterObjScript.DoInteraction(); audioSource.clip = dooropening; audioSource.pitch = 1f; audioSource.PlayOneShot(dooropening); } else { // key was not found: door stays locked and plays sound. Debug.Log("locked"); currentInterObjScript.locked = true; audioSource.clip = doorlocked; audioSource.pitch = 1f; audioSource.Play(); Debug.Log(currentInterObj.name + " was not unlocked"); } } else { Debug.Log(currentInterObj.name + " is open"); } } currentInterObj = null; } }