I have a problem with inventory dissapearing when equipping an empty weapon with UIS integration. I have included the full stack to show the sequence of how this occurs.
When the empty weapon is equipped, if there is matching Ammo in the inventory, the clipsize is consumed, but it does not get loaded into the weapons clip. It just dissapears.
I think the problem is in the ShootableWeapon.cs script, SetAmmoToshootableWeapon. This calls SetConsumableItemIdentifer which calls ReloadItem that triggers the inventory to be consumed. But when this returns to SetAmmoToShootableWeapon, the ammo amount is set to the ClipRemaining, which wipes the inventory that was just consumed. I don't think that SetConsumableItemIdentifier should call ReloadItem in this situation? (Note, auto-reload is set to nothing, so ShootableWeapon should never try to reload automatically, regardless)
You can see in the stack, this all gets triggered initially via the BridgeEquippableProcessing line 242 when it sets the item info.
In SetConsumableItemIdentifier, the method would return without doing the reload if this evaluated to true: (m_ConsumableItemIdentifier == itemIdentifier) Which led me to think my ShootableWeapon component on the prefab was not setup correctly. But looking at component below, it looked ok? In fact in the ShootableWeapon Awake it changes the value of m_ConsumableItemIdentifier from the value it initialises with to a new value. The initialised value would have matched the evaluation above?
Thanks in advance for your help. As always, I tried to track the problem down before posting, but I am lost.
I just upgraded to latest versions (But I think this problem was there before and I was just ignoring it)
UIS Version: 1.2
UCC Version: 2.4
When the empty weapon is equipped, if there is matching Ammo in the inventory, the clipsize is consumed, but it does not get loaded into the weapons clip. It just dissapears.
I think the problem is in the ShootableWeapon.cs script, SetAmmoToshootableWeapon. This calls SetConsumableItemIdentifer which calls ReloadItem that triggers the inventory to be consumed. But when this returns to SetAmmoToShootableWeapon, the ammo amount is set to the ClipRemaining, which wipes the inventory that was just consumed. I don't think that SetConsumableItemIdentifier should call ReloadItem in this situation? (Note, auto-reload is set to nothing, so ShootableWeapon should never try to reload automatically, regardless)
You can see in the stack, this all gets triggered initially via the BridgeEquippableProcessing line 242 when it sets the item info.
In SetConsumableItemIdentifier, the method would return without doing the reload if this evaluated to true: (m_ConsumableItemIdentifier == itemIdentifier) Which led me to think my ShootableWeapon component on the prefab was not setup correctly. But looking at component below, it looked ok? In fact in the ShootableWeapon Awake it changes the value of m_ConsumableItemIdentifier from the value it initialises with to a new value. The initialised value would have matched the evaluation above?
C#:
if (m_ConsumableItemDefinition != null) {
m_ConsumableItemIdentifier = m_ConsumableItemDefinition.CreateItemIdentifier();
}
Thanks in advance for your help. As always, I tried to track the problem down before posting, but I am lost.
I just upgraded to latest versions (But I think this problem was there before and I was just ignoring it)
UIS Version: 1.2
UCC Version: 2.4
C#:
private void SetAmmoToShootableWeapon(AmmoData value)
{
if (value.ItemDefinition != null) {
m_ShootableWeapon.SetConsumableItemIdentifier(value.ItemDefinition.DefaultItem);
}
m_ShootableWeapon.SetConsumableItemIdentifierAmount(value.ClipRemaining);
m_ShootableWeapon.ClipSize = value.ClipSize;
}
public override void SetConsumableItemIdentifier(IItemIdentifier itemIdentifier)
{
if (m_ConsumableItemIdentifier == itemIdentifier) {
return;
}
// Add back the previous consumable item to the inventory.
m_Inventory.AdjustItemIdentifierAmount(m_ConsumableItemIdentifier, ClipRemaining);
m_ConsumableItemIdentifier = itemIdentifier;
m_ConsumableItemDefinition = itemIdentifier.GetItemDefinition();
// Set the ClipRemaining to 0 so the new consumable item can be loaded from the inventory.
ClipRemaining = 0;
ReloadItem(false);
}
Code:
Int32 Opsive.UltimateInventorySystem.Core.InventoryCollections.BackPackItemCollection:RemoveItemFromStack (Int32, ItemInfo, Int32, Int32, Int32, Int32)+0x22 at G:\UnityProjects\DeadFear2\DeadFear2\Assets\DeadFear\Opsive\UltimateInventorySystem\Scripts\Core\InventoryCollections\BackPackItemCollection.cs:[177:13-177:45] C#
ItemInfo Opsive.UltimateInventorySystem.Core.InventoryCollections.BackPackItemCollection:RemoveInternal (ItemInfo)+0x55 at G:\UnityProjects\DeadFear2\DeadFear2\Assets\DeadFear\Opsive\UltimateInventorySystem\Scripts\Core\InventoryCollections\BackPackItemCollection.cs:[129:17-130:101] C#
ItemInfo Opsive.UltimateInventorySystem.Core.InventoryCollections.ItemCollection:RemoveItem (ItemInfo)+0x36 at G:\UnityProjects\DeadFear2\DeadFear2\Assets\Opsive\UltimateInventorySystem\Scripts\Core\InventoryCollections\ItemCollection.cs:[728:13-728:51] C#
ItemInfo Opsive.UltimateInventorySystem.Core.InventoryCollections.ItemCollection:RemoveItem (Item, Int32)+0xf at G:\UnityProjects\DeadFear2\DeadFear2\Assets\Opsive\UltimateInventorySystem\Scripts\Core\InventoryCollections\ItemCollection.cs:[739:13-739:53] C#
Void Opsive.UltimateCharacterController.Integrations.UltimateInventorySystem.CharacterInventoryBridge:AdjustItemIdentifierAmountInternal (IItemIdentifier, Int32)+0x8d at G:\UnityProjects\DeadFear2\DeadFear2\Assets\Opsive\UltimateCharacterController\Integrations\UltimateInventorySystem\Scripts\CharacterInventoryBridge.cs:[889:25-889:75] C#
Void Opsive.UltimateCharacterController.Inventory.InventoryBase:AdjustItemIdentifierAmount (IItemIdentifier, Int32)+0x15 at G:\UnityProjects\DeadFear2\DeadFear2\Assets\Opsive\UltimateCharacterController\Scripts\Inventory\InventoryBase.cs:[473:13-473:72] C#
Void Opsive.UltimateCharacterController.Items.Actions.ShootableWeapon:ReloadItem (Boolean)+0x18c at G:\UnityProjects\DeadFear2\DeadFear2\Assets\Opsive\UltimateCharacterController\Scripts\Items\Actions\ShootableWeapon.cs:[1593:13-1593:95] C#
Void Opsive.UltimateCharacterController.Items.Actions.ShootableWeapon:SetConsumableItemIdentifier (IItemIdentifier)+0x46 at G:\UnityProjects\DeadFear2\DeadFear2\Assets\Opsive\UltimateCharacterController\Scripts\Items\Actions\ShootableWeapon.cs:[528:13-528:31] C#
Void ShootableWeaponAmmoBinding:SetAmmoToShootableWeapon (AmmoData)+0x25 at G:\UnityProjects\DeadFear2\DeadFear2\Assets\Opsive\UltimateCharacterController\Integrations\UltimateInventorySystem\Scripts\ItemBindings\ShootableWeaponAmmoBinding.cs:[66:13-66:93] C#
Void ShootableWeaponAmmoBinding:SetItem (Item)+0xcf at G:\UnityProjects\DeadFear2\DeadFear2\Assets\Opsive\UltimateCharacterController\Integrations\UltimateInventorySystem\Scripts\ItemBindings\ShootableWeaponAmmoBinding.cs:[154:9-154:46] C#
Void ShootableWeaponAmmoBinding:SetItem ()+0x1d at G:\UnityProjects\DeadFear2\DeadFear2\Assets\Opsive\UltimateCharacterController\Integrations\UltimateInventorySystem\Scripts\ItemBindings\ShootableWeaponAmmoBinding.cs:[119:13-119:40] C#
Void Opsive.Shared.Events.InvokableAction:Invoke ()+0x6 at :-1 C#
Void Opsive.Shared.Events.EventHandler:ExecuteEvent (Object, String)+0x28 at :-1 C#
> Void Opsive.UltimateInventorySystem.Core.ItemObject:SetItem (ItemInfo)+0xc6 at G:\UnityProjects\DeadFear2\DeadFear2\Assets\Opsive\UltimateInventorySystem\Scripts\Core\ItemObject.cs:[137:13-137:84] C#
Item Opsive.UltimateCharacterController.Integrations.UltimateInventorySystem.BridgeEquippableProcessing:CreateCharacterItem (ItemInfo, Item)+0x51 at G:\UnityProjects\DeadFear2\DeadFear2\Assets\Opsive\UltimateCharacterController\Integrations\UltimateInventorySystem\Scripts\BridgeEquippableProcessing.cs:[242:13-242:42] C#
Item Opsive.UltimateCharacterController.Integrations.UltimateInventorySystem.BridgeEquippableProcessing:CreateCharacterItem (ItemInfo, GameObject)+0x2b at G:\UnityProjects\DeadFear2\DeadFear2\Assets\Opsive\UltimateCharacterController\Integrations\UltimateInventorySystem\Scripts\BridgeEquippableProcessing.cs:[223:13-223:80] C#
ItemInfo Opsive.UltimateCharacterController.Integrations.UltimateInventorySystem.BridgeEquippableProcessing:OnItemAddedToEquippable (ItemInfo, ItemStack)+0x190 at G:\UnityProjects\DeadFear2\DeadFear2\Assets\Opsive\UltimateCharacterController\Integrations\UltimateInventorySystem\Scripts\BridgeEquippableProcessing.cs:[184:17-184:79] C#
Last edited: