Can't Equip Melee Weapon

magique

Active member
Using Unity 2019.3.8f1 and the latest Asset store version of Third person controller.

I followed the steps to create a melee weapon directly on an existing character. That's been working fine so far, but I don't want the weapon to start equipped so I disabled the item in the Item Set Manager and provided a holstered position. Now the character starts with the weapon holstered on his back as expected. However, when I press the Equip button (Y on the joystick or e on the keyboard), the weapon never equips. This works fine in the demo scene, but I can't find any differences there.
 
Last edited:
so I disabled the item in the Item Set Manager
By disabling the Item Set you are going to prevent the item from being equipped at all. The Item Set should remain enabled, and if you don't want the character to start with the item you should remove it from the default loadout. If you want the item to be in the default loadout but not equipped then you should add a new Item Set that the character can start with.
 
OK, I understand all that now, but that doesn't fix the issue where I am unable to unequip and re-equip it using the button. Or does it?
 
The only think I could try from your answer was to create another Item set, which I am assuming you meant to say should be empty. So, I gave that a try, but it didn't have any affect at all. I even set the empty set as the default, but it started with the Sword in hand instead. So, I'm puzzled as to how to make this work.
 
I checked Nolan and there was an Item Set with Body Type. So I added the same for my character and even set as Default, but it still had the Sword equipped. So, I noticed that the Default Loadout I had set to Sword type. So I changed that to Body Type. So, two things with that setup. First, the Sword is completely gone and not even in the holstered position. I only get it in the Holstered position when I have the Sword Item Set with Enabled unchecked. Second, pressing the Equip button still has no effect.
 
I think I know what I did wrong. I didn't add a Body item to the character. However, when I went to revert everything and start with just a sword again, I broke it. Now, when I start the game, it takes the sword item from the bones Item hierarchy and puts it under the Holstered transform and the Holstered transform is disabled so the sword isn't even visible. And there seems to be no way to fix this.
 
OK, figured that last part out. The inventory count for the sword type was 0. Going to try now to add a Body Item to the character and see if that works.
 
I give up. Even when I add a Body item and make sure it's in the default loadout with a quantity, it doesn't work. It still just has the sword in hand and doesn't change to Body when pressing the Equip button.
 
On the EquipUnequip ability you can specify when an item should be auto equipped. Try setting that enum to nothing. I would also go through this video which talks about setting up the sword and body items:


This video was made with 2.2 (which was just released). I would get it working like the video and then it should be easy to adjust from there.
 
On the EquipUnequip ability you can specify when an item should be auto equipped. Try setting that enum to nothing. I would also go through this video which talks about setting up the sword and body items:


This video was made with 2.2 (which was just released). I would get it working like the video and then it should be easy to adjust from there.
Thanks for the video. The only one I found was the one that shows how to do the assault rifle. I will definitely try over again with this video and see how it turns out.
 
On the EquipUnequip ability you can specify when an item should be auto equipped. Try setting that enum to nothing. I would also go through this video which talks about setting up the sword and body items:


This video was made with 2.2 (which was just released). I would get it working like the video and then it should be easy to adjust from there.
I finally got back to this and following the video tutorial. And there is an issue with your video. Following the steps exactly does not produce the outcome the video shows. When you get to the 2:55 mark of the video and hit play, the sword is not visible and equipped. I remember this from before. Whatever it is, I don't know, but that doesn't work as expected. And even though the setup has Add to Default Loadout, there is nothing in the default loadout after these steps nor are there any items in the Item Set Manager.

Previously I would hack around this and add the loadout and items, but maybe doing all that causes all the other issues I was having. I want to stop here and see if you can help me so that when I am at 2:55 in the video it is set up correctly and I don't have to fix it manually.
 
I found the issue. I double checked the Sword and Body item types that I created and they had a capacity of max int value. I never entered that obviously so it seems like some sort of Opsive bug. I will continue now from the 2:55 point and see how it all turns out.
 
Still having issues. I messed up the first time so I needed to start over, but I don't know exactly how to undo adding an Item to the character so it's clean and is ready to start over. I ended up forgetting to remove the first Sword from the bone hierarchy and after adding the second time, it had 2 items and that messed me up. So I deleted both swords from the bone hierarchy and the Items hierarchy, but now it just get a null reference exception that the item has o collider, but it does have a collider. And I still never see a default loadout or items in the collection.
'm going to start over from scratch with the character all over again because I just don't know how to get around this.
 
OK, so I started my character over completely from scratch and added a Sword item to my character just as the video shows. But when I run, the sword does not appear in the hand and I get the following runtime error:

NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateCharacterController.Inventory.ItemSetManagerBase.IsCategoryMember (Opsive.Shared.Inventory.IItemCategoryIdentifier itemCategory, System.Int32 categoryIndex) (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/ItemSetManagerBase.cs:117)
Opsive.UltimateCharacterController.Inventory.ItemSetManagerBase.IsCategoryMember (Opsive.Shared.Inventory.IItemCategoryIdentifier itemCategory, System.Int32 categoryIndex) (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/ItemSetManagerBase.cs:122)
Opsive.UltimateCharacterController.Inventory.ItemSetManagerBase.IsCategoryMember (Opsive.Shared.Inventory.ItemDefinitionBase itemDefinition, System.Int32 categoryIndex) (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/ItemSetManagerBase.cs:101)
Opsive.UltimateCharacterController.Character.Abilities.Items.EquipUnequip.OnPickupItemIdentifier (Opsive.Shared.Inventory.IItemIdentifier itemIdentifier, System.Int32 amount, System.Boolean immediatePickup, System.Boolean forceEquip) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/Abilities/Items/EquipUnequip.cs:322)
Opsive.Shared.Events.InvokableAction`4[T1,T2,T3,T4].Invoke (T1 arg1, T2 arg2, T3 arg3, T4 arg4) (at <e1dc8cf082ab4226a2cfe9b11461b1b5>:0)
Opsive.Shared.Events.EventHandler.ExecuteEvent[T1,T2,T3,T4] (System.Object obj, System.String eventName, T1 arg1, T2 arg2, T3 arg3, T4 arg4) (at <e1dc8cf082ab4226a2cfe9b11461b1b5>:0)
Opsive.UltimateCharacterController.Inventory.InventoryBase.ItemIdentifierPickedUp (Opsive.Shared.Inventory.IItemIdentifier itemIdentifier, System.Int32 amount, System.Int32 slotID, System.Boolean immediatePickup, System.Boolean forceEquip) (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/InventoryBase.cs:264)
Opsive.UltimateCharacterController.Inventory.InventoryBase.Pickup (Opsive.Shared.Inventory.IItemIdentifier itemIdentifier, System.Int32 amount, System.Int32 slotID, System.Boolean immediatePickup, System.Boolean forceEquip, System.Boolean notifyOnPickup) (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/InventoryBase.cs:222)
Opsive.UltimateCharacterController.Inventory.InventoryBase.Pickup (Opsive.Shared.Inventory.IItemIdentifier itemIdentifier, System.Int32 amount, System.Int32 slotID, System.Boolean immediatePickup, System.Boolean forceEquip) (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/InventoryBase.cs:188)
Opsive.UltimateCharacterController.Inventory.Inventory.LoadDefaultLoadout () (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/Inventory.cs:49)
Opsive.UltimateCharacterController.Inventory.InventoryBase.Start () (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/InventoryBase.cs:118)

And this error:


NullReferenceException: Object reference not set to an instance of an object
Opsive.UltimateCharacterController.Inventory.ItemSetManagerBase.AddItem (Opsive.UltimateCharacterController.Items.Item item, Opsive.Shared.Inventory.IItemCategoryIdentifier category) (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/ItemSetManagerBase.cs:209)
Opsive.UltimateCharacterController.Inventory.ItemSetManagerBase.AddItem (Opsive.UltimateCharacterController.Items.Item item, Opsive.Shared.Inventory.IItemCategoryIdentifier category) (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/ItemSetManagerBase.cs:212)
Opsive.UltimateCharacterController.Inventory.ItemSetManagerBase.OnAddItem (Opsive.UltimateCharacterController.Items.Item item) (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/ItemSetManagerBase.cs:197)
Opsive.Shared.Events.InvokableAction`1[T1].Invoke (T1 arg1) (at <e1dc8cf082ab4226a2cfe9b11461b1b5>:0)
Opsive.Shared.Events.EventHandler.ExecuteEvent[T1] (System.Object obj, System.String eventName, T1 arg1) (at <e1dc8cf082ab4226a2cfe9b11461b1b5>:0)
Opsive.UltimateCharacterController.Inventory.InventoryBase.AddItem (Opsive.UltimateCharacterController.Items.Item item, System.Boolean immediateEquip, System.Boolean forceEquip) (at Assets/Opsive/UltimateCharacterController/Scripts/Inventory/InventoryBase.cs:157)
Opsive.UltimateCharacterController.Items.Item.Start () (at Assets/Opsive/UltimateCharacterController/Scripts/Items/Item.cs:350)
 
Got it. For some reason my Sword Item Type no longer had a category even though I know I set it up correctly. I made it Items category and now it is equipped and working. So far.
 
Great. Now I'm back to an old issue where after swinging the sword once, it never swings again and the upper body is just stuck and won't animate. Trying to remember what causes this issue now. I have to write these things down.
 
I found the Allow Attack Combos and disabled it because it definitely was warning me. But it didn't fix it.
 
Got the attacking combo part worked out. I'll do the rest of the video tomorrow and report here if I have another issue.
 
Top