Hello all my game is coming along great thanks to all the help from everyone in the community i am here again to ask for some guidance I downloaded the free inventory system that Brackeys made available for free Unity Asset Store - The Best Assets for Game Making I got it into my game its working the only thing is that when I use say the water to replenish the thirst bar the hunger bar and energy bar also go up, and I only want to affect the thirst bar when I use the water here is the script
#pragma strict
//This script allows you to insert code when the Item is used (clicked on in the inventory).
var deleteOnUse = true;
private var playersInv : Inventory;
private var item : Item;
@script AddComponentMenu ("Inventory/Items/Item Effect")
@script RequireComponent(Item)
//This is where we find the components we need
function Awake ()
{
playersInv = FindObjectOfType(Inventory); //finding the players inv.
if (playersInv == null)
{
Debug.LogWarning("No 'Inventory' found in game. The Item " + transform.name + " has been disabled for pickup (canGet = false).");
}
item = GetComponent(Item);
}
//This is called when the object should be used.
function UseEffect ()
{
Thirst.tcurHP += 25;
Hunger.curHP += 25;
//Play a sound
playersInv.gameObject.SendMessage("PlayDropItemSound", SendMessageOptions.DontRequireReceiver);
//This will delete the item on use or remove 1 from the stack (if stackable).
if (deleteOnUse == true)
{
DeleteUsedItem();
}
}
//This takes care of deletion
function DeleteUsedItem()
{
if (item.stack == 1) //Remove item
{
playersInv.RemoveItem(this.gameObject.transform);
}
else //Remove from stack
{
item.stack -= 1;
}
Debug.Log(item.name + " has been deleted on use");
}
the problem starts at line 25 where I added the function to be able to use the pick ups any help on how to repair this will be greatly appreciated have a great weekend and happy game making. -K