I don’t know why but I get a null reference exception every time i call this function:
function AddToInventory () {
var inventory = player.GetComponent(Inventory);
isTrigger = true;
inventory.AddItem(this);
transform.position = inventory.transform.position;
}
I am sending the information here, to this function:
function AddItem (item : GameObject) {
icon = item.GetComponent(Texture);
items.Add(item);
}
it tells me that the object i’m sending is not set to an instance of an object.
what am I doing wrong here?