Storing Prefab in an Array

So I am creating an inventory script where the player is able to store items by placing them in an array, the object is then removed from the scene

However, deleting the scene reference deletes the object in the array. How can I store the information for the items and remove them from the scene?

I’ve made sure that the object in the array is in a prefab. It is important that the object is deleted, and that all the information from the prefab is stored.

1 Answer

1

An easier way of doing this would be to simply de-activate the gameObject when it’s placed in the inventory. Then, when it’s retrieved from the inventory you activate it again and you set it’s position to the ‘spawnposition’ of the ‘new’ gameobject. This way you can avoid having to keep creating and destroying GO’s, but you rather just hide them for later.

The biggest problem is that I will be moving through scenes constantly, and the item needs to remain in the player's inventory. So I need to set the reference of the object, instead of the object it's self.

Bingo! remember if my answer helped you, mark it correct do others can find it in the future ;)