I was wondering how I would go about setting up a variable in my code that whenever I interacted with a certain game object the number for that variable would go down. So far, I have code that allows the player to interact with the object in the first place after pressing a button.
void Update() {
if (Input.GetButtonDown ("Interact") && currentInterObj) {
if (currentInterObjScript.npc) {
currentInterObj.SendMessage ("TriggerDialogue");
}
if (currentInterObjScript.interactable) {
currentInterObj.SendMessage ("GoToClass");
}
if (currentInterObjScript.inventory) {
inventory.AddItem (currentInterObj);
currentInterObj.SendMessage ("DoInteraction");
}
}
if (Input.GetButtonDown ("Continue") && currentInterObj) {
if (currentInterObjScript.npc) {
currentInterObj.SendMessage ("ContinueDialogue");
}
}
}