Hello, i’m french but i think find more answers in this forum. Sorry if my english is bad.
I try to call a parent fonction when an evenement “on trigger enterer” is coming in a child class.
Child class :
public class PickUp : MonoBehaviour {
public Item item;
Inventory inventoryScript;
void OnTriggerEnter(Collider other)
{
inventoryScript.AddItem(item);
}
}
And my parent class :
public class Inventory : MonoBehaviour {
public const int nbSlots = 30;
public Item[] items = new Item[nbSlots];
public GameObject A1;
public void AddItem(Item itemToAdd)
{
for (int i = 0; i < items.Length; i++)
{
if (items *== null)*
{
items = itemToAdd;
A1.GetComponent().sprite = itemToAdd.sprite;
return;
}
}
}
}
My error appear in “PickUp” script at line 13 : inventoryScript.AddItem(item);
thank you in advance