I got the basics of my item system working, however I can't figure out how to re-instantiate an item from the inventory into the world again in order to drop it.
My current problem is the fact that the prefab variable my ItemData has, is assigned to the instance of the prefab instead of the prefab, so when I destroy the Item GameObject and add the ItemData, the reference which I use to instantiate it is invalid.
![alt text][1]
The first line to the left, is the instance of the prefab in the bottom. The second line to the right shows what the Prefab variable is connected to.
And this picture shows how things look when I picked the item up into the inventory. Since the Item instance was deleted, the Prefab variable of the ItemData in the inventory is invalid. The thing is, I don't want it to reference the instance, I want it to reference the prefab.
![alt text][2]
What would be a good solution to this problem? I considered a database with all items, but that feels kinda overkill. (My game will most likely have a lot of items)
Here are the fixed working scripts, added them as links to pastebin:
[ItemData.cs][3]
[Item.cs][4]
[Inventory.cs][5]
[1]: /storage/temp/110434-skarmklipp.png [2]: /storage/temp/110435-skarmklipp2.png [3]: https://pastebin.com/rKTAyyn4 [4]: https://pastebin.com/FzKzXb0P [5]: https://pastebin.com/aBaQZJjU
My current problem is the fact that the prefab variable my ItemData has, is assigned to the instance of the prefab instead of the prefab, so when I destroy the Item GameObject and add the ItemData, the reference which I use to instantiate it is invalid.
![alt text][1]
The first line to the left, is the instance of the prefab in the bottom. The second line to the right shows what the Prefab variable is connected to.
And this picture shows how things look when I picked the item up into the inventory. Since the Item instance was deleted, the Prefab variable of the ItemData in the inventory is invalid. The thing is, I don't want it to reference the instance, I want it to reference the prefab.
![alt text][2]
What would be a good solution to this problem? I considered a database with all items, but that feels kinda overkill. (My game will most likely have a lot of items)
Here are the fixed working scripts, added them as links to pastebin:
[ItemData.cs][3]
[Item.cs][4]
[Inventory.cs][5]
[1]: /storage/temp/110434-skarmklipp.png [2]: /storage/temp/110435-skarmklipp2.png [3]: https://pastebin.com/rKTAyyn4 [4]: https://pastebin.com/FzKzXb0P [5]: https://pastebin.com/aBaQZJjU