void CheckPlayerInput() { if (_itemsToDetect != null && _itemsToDetect.Count > 0) { if (Input.GetButtonDown(buttonPickUp) && Time.timeScale > 0) { Player_Controller.animator.Play("Grab/Push"); List <GameObject> itemsToBePickedUp = new List <GameObject>(); foreach (GameObject item in _itemsToDetect) { itemsToBePickedUp.Add(item); } foreach (GameObject itemToBeCollected in itemsToBePickedUp) { _itemsToDetect.Remove(itemToBeCollected); _playerInventory.AddItemToInventory(itemToBeCollected); } } } }