0
Answered

Adding object to inventory

Kevin 9 months ago in Inventory updated by Marti (Lead Developer) 9 months ago 1

Hi.

I'm having trouble removing an object from a scene when it gets added to my inventory. Basically the item displays in the inventory but remains in the scene also.  The object is showing in the hierarchy as a prefab rather than a game object.  Is this the problem?  I notice that in the inventory example, the icons are game objects with prefab child icons.  I'm not sure how to rectify this.

Thanks in advance.

Unity version:
2018.4.5f1
Game Creator version:
1.0.1

Answer

Answer
Answered

In order to remove an object from the scene, you can either use the Destroy action or use the "Destroy After Finishing" checkbox at the end of an Actions object. However, make sure you place the Actions component at the root of your prefab. Otherwise, it will only destroy the child game object where the Actions are.

As for the game object looking like a prefab, it's normal. If you create a prefab out of a scene object, it will appear in blue inside your scene.

As for the last question, I'm not sure I fully understand what you mean by "in the Inventory example, the icons are game objects with prefab child icons". The icon of an item is set at the Item's Catalogue configuration window (see documentation: https://docs.gamecreator.io/inventory/inventory/inventory-window/catalogue). When using the "Item" action to add an item to the Player's inventory, it will use the Item's Sprite to display the icon of the item in the Player's Inventory UI window.

Hope this helps. If something's not clear, let me know

GOOD, I'M SATISFIED
Satisfaction mark by Kevin 9 months ago
Answer
Answered

In order to remove an object from the scene, you can either use the Destroy action or use the "Destroy After Finishing" checkbox at the end of an Actions object. However, make sure you place the Actions component at the root of your prefab. Otherwise, it will only destroy the child game object where the Actions are.

As for the game object looking like a prefab, it's normal. If you create a prefab out of a scene object, it will appear in blue inside your scene.

As for the last question, I'm not sure I fully understand what you mean by "in the Inventory example, the icons are game objects with prefab child icons". The icon of an item is set at the Item's Catalogue configuration window (see documentation: https://docs.gamecreator.io/inventory/inventory/inventory-window/catalogue). When using the "Item" action to add an item to the Player's inventory, it will use the Item's Sprite to display the icon of the item in the Player's Inventory UI window.

Hope this helps. If something's not clear, let me know