How to add a looting window

Adding an option to store inventory items in another game object , apart from the player inventory?.

I would start with this post: Making Inventory Containers (Banks, NPC loots, Treasure Chests)

It walks you through the changes needed to make a World of Warcraft style bank within your scene, but it can also be applied to a looting window… the enemy itself, for example, could be a lootable source by making the mentioned IRayCastable disabled until the enemy dies.

1 Like

Thanks, do you have forms or ways to add items into the loot window?

May you give me some ideas on how to add items into an inventory.

Take a look at Inventory.cs and the AddToFirstEmptySlot() method.

1 Like
/// <summary>
        /// Attempt to add the items to the first available slot.
        /// </summary>
        /// <param name="item">The item to add.</param>
        /// <param name="number">The number to add.</param>
        /// <returns>Whether or not the item could be added.</returns>
        public bool AddToFirstEmptySlot(InventoryItem item, int number)
        {
            int i = FindSlot(item);

            if (i < 0)
            {
                return false;
            }

            slots[i].item = item;
            slots[i].number += number;
            if (inventoryUpdated != null)
            {
                inventoryUpdated();
            }
            return true;
        }

But how I know the exact item. I want to put. Sorry if it’s a dumb question,

You already have a RandomItemDropper method. The RandomItemDropper should get a reference to the enemy’s inventory (you’ll have to add an inventory to the enemy). Instead of calling DropItem(), call inventory.AddToFirstEmptySlot() instead.

Thank you very much, will try it.

This topic was automatically closed after 23 hours. New replies are no longer allowed.

Privacy & Terms