- Home /
Confirming item pickup in inventory
A friend and I are build a game together and currently I'm building the item collection system off of his code. The way the code works, when you open the menu, a series of items appear. These items will be greyed out if they are not obtained. The script checks the presence of the item via this script
public void foundItem(int symbolNum){
//Iterates through all the clue items based off the length of images there are
//If the itemNum = images[ itemNum - 1] you have found the item
//Set the item that you have found to isFound = true
//Set the newly found item image to a visible transpency
print ("Looking for item# "+symbolNum);
//If the clue value is the same as symbol value, proceed
GameObject[] clueSymbolGOs = GameObject.FindGameObjectsWithTag("ClueSymbol");
//We are now looking for the clueItem i that matches s (symbol number)
foreach(GameObject clue in clueSymbolGOs){
if(clue.GetComponent<ClueBehaviour>().getClueSymbol() == symbolNum){
print ("Found clue symbol game object # "+ symbolNum);
//clue.GetComponent<GUITexture>().texture = symbolHolder;
//this.gameObject.GetComponent<GUITexture> ().texture = images[itemNum];
clue.GetComponent<ClueBehaviour>().isFound = true;
clue.GetComponent<GUITexture>().color = new Color(.5f,.5f,.5f,.5f);
}
}
}
This is not the whole of the script, but the section I am working with. From what I understand, I need to make a code that, when the appropriate item is found, will toggle a bool in a separate script. When the inventory is opened, the separate script will check if the bool is toggled, and if so, change the corresponding cluesymbol's isfound to true, thus marking the item has held. I have a feeling I'm either missing something or overcomplicating things though. Can anyone help me clarify how to make this work?
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
how do i make projectile spawnpoint disabled in cam1 1 Answer
Raycast Hit not toggling variable if stops hitting 1 Answer
Multiple objects sharing a boolean variable in a script. 1 Answer
Simple Backpack "Pick up and drop" 1 Answer