void OnTriggerEnter(Collider other)
{
if (other.tag == “Item”)
{
AddItem(other.gameObject);
}
}
void AddItem(GameObject item)
{
string databaseItem = ("/" + "ItemDatabase" + "/" + item.name);
item_copy = GameObject.Find(databaseItem);
print(item_copy);
print(item.name);
item.SetActive(false);
}
I have an OnTriggerEnter() function that calls this when an object with the tag “Item” goes inside the player’s pick up radius.
In the first line i am making a string to put into the .Find which is supposed to look inside the empty gameobject titled “ItemDatabase” and then the look for the item that shares the same title with the picked up item.
However, this is where i run into a problem, when i print the item.name it prints out the name, but when i print out item copy, it prints out “Null” and im not sure what is going on here. (I have also tried to do item_copy.name, that causes another problem)