I’ve spent the entire day trying to figure this out to no avail. I have created a script for a simple inventory and I am trying to make the item I want the player to be able to pick up add to the inventory. Its a really simple text inventory but it doesn’t seem to work. Here’s the code for the inventory:
#pragma strict
var showGUI : boolean = false;
var woodInv : int;
woodInv = woodPickup.woodInvAmount;
function Update ()
{
if (Input.GetKeyDown(KeyCode.F))
{
if(showGUI == false)
{
showGUI = true;
Debug.Log("showGUI = true");
} else{
showGUI = false;
Debug.Log("showGUI = false");
}
}
}
function OnGUI()
{
if(showGUI == true)
{
GUI.Box (Rect (10,10,100,90), "Inventory");
GUI.Label (Rect (15,35,40,30), "Wood:");
GUI.Label (Rect (75,35,40,30), " " + woodInv);
}
}
And here is the code for the wood pickup item:
#pragma strict
static var woodInvAmount : int = 0;
function OnTriggerEnter (Col : Collider)
{
if(Col.tag == "Player")
{
++woodInvAmount;
Destroy(gameObject);
}
}
Any Help would be very much appreciated!
*P.S. This is in UnityScript