UCC3 Drop Ability Not Working With UIS Integration

Exi-G

New member
As I mentioned on the discord channel, if I try to drop an item using the UCC Drop ability with the UIS integration then the item disappear. But if I try with the default UCC demo scene then the item is dropped on the ground.

here is a video showing the issue: https://streamable.com/br4usy
 

Sangemdoko

Moderator
Staff member
Thank you for reporting this bug.
I was able to fix it but it required a few changes to both UCC, UIS and the integration, so it could take awhile for the fix to be available in the next update.

if you cannot wait for the update, here are the changes that should be relevant to your particular issue:

InventoryBase.cs

Change
Code:
protected virtual (int amountRemoved, GameObject dropInstance) RemoveItemIdentifierAmountInternal(IItemIdentifier itemIdentifier, int slotID, int amount, bool drop, bool removeCharacterItem, bool destroyCharacterItem)
        {
            GameObject dropInstance = null;
            if (itemIdentifier == null || amount <= 0) {
                return (0, dropInstance);
            }

            if (drop) {
                dropInstance = TryDropItemInstance(itemIdentifier, slotID, amount);
            }
            
            
            ....

Add this
Code:
/// <summary>
        /// Try to drop an item.
        /// </summary>
        /// <param name="itemIdentifier">The item identifier to drop.</param>
        /// <param name="slotID">The slot id of the item to drop.</param>
        /// <param name="amount">The amount to drop.</param>
        /// <returns>The dropped instance.</returns>
        protected virtual GameObject TryDropItemInstance(IItemIdentifier itemIdentifier, int slotID, int amount)
        {
            GameObject dropInstance = null;
            if (TryGetCharacterItem(itemIdentifier, slotID, out var characterItem)) {
                dropInstance = DropCharacterItem(characterItem, amount, false, false);
            } else if (m_DropPrefab != null) {
                var dropPosition = transform.position + transform.TransformDirection(m_DropOffset);
                var dropRotation = transform.rotation;
                var dropAmount = new ItemIdentifierAmount(itemIdentifier, amount);
                dropInstance = DropItemIdentifiers(m_DropPrefab, dropPosition, dropRotation, dropAmount, false, false);
            }

            return dropInstance;
        }

in CharacterInventoryBridge.cs override that new function by adding this:

Code:
/// <summary>
/// Try to drop an item.
/// </summary>
/// <param name="itemIdentifier">The item identifier to drop.</param>
/// <param name="slotID">The slot id of the item to drop.</param>
/// <param name="amount">The amount to drop.</param>
/// <returns>The dropped instance.</returns>
protected override GameObject TryDropItemInstance(IItemIdentifier itemIdentifier, int slotID, int amount)
{
    var itemInfo = new ItemInfo(itemIdentifier as Item, amount);
    var inventory = DropItem(itemInfo,false, false);
    return inventory?.gameObject;
}

In ItemSlotCollection.cs around line 322 replace this

Code:
if (removed.ItemStack.IsInitialized && removed.ItemStack.ItemCollection == this) {
    m_ItemsBySlot[slotIndex] = removed.ItemStack;
} else {
    m_ItemsBySlot[slotIndex] = null;
}

That should allow you to drop items as expected using the UCC drop action to drop items the integration way.
Do let me know if you find any other issues
 
Top