Quantcast
Channel: Questions in topic: "slot"
Viewing all articles
Browse latest Browse all 109

Destroy Item Visuals but store a version of it

$
0
0
Hi guys. I am trying to create an Inventory which fills after gathering items like Coins etc. My problem is that whenever I Destroy() the GameObject of the coin after adding it to an Array in my Inventory Component it will also miss the reference to the stored GameObject in the Array. Code: collision.gameObject.GetComponent(Inventory).AddItem(this.gameObject); Destroy(this.gameObject); ---------------------------------------------------------------------------------- //Add Item to the First free Slot in the Inventory //Overload 1: Add Item to a Specific slot in the Inventory function AddItem(item:GameObject):void { AddItem(item,GetFirstFreeItemSlot()); } function AddItem(item:GameObject, slot:int):void { //Check if there is a Item in that Specific Slot already if(slot >= 0 && itemSlots[slot] == null) { itemSlots[slot] = item; print("Inventory: The Inventory now contains: " + itemSlots[slot].GetComponent(ObtainableItem).itemName); } }

Viewing all articles
Browse latest Browse all 109

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>