Using the same weapon for both Left and Right hands

Shizof

New member
Hello, I'm having trouble making a sword dual wield (not two handed). I know that it's already possible if I make a Left Sword and a Right Sword item types. But is it possible to make Sword item type be equipped in left or right hands or both at the same type if you have two of them?

In the documentation, it's explained for Sword and Shield (Two different items) for a normal RPG game which would have a lot of different types, which is what I'm going for. I want the game to have lots of different one handed swords, shields etc. but I want them to be equipped at the same time as well if I have two of the same item.

But even with the same setup in the documentation, I couldn't switch to the item set in game. I defined Sword item type to be in only Right Hand Item category and then I created right hand item sets in Item Set Manager, left the left one empty for later. But then the character cannot switch to the right item set, only the main Items set which only has the Body item type which is for fists. Is there another place to define the new "Left Hand Items" and "Right Hand Items" categories so that they are switchable as well? I found under Ultimate Character Locomotion script, under Equip Unequip or Equip Next/Equip Previous/Equip Scroll item abilities, there is a "ItemSet Category" setting. But that only allows 1 category. Do I need to define new abilities for other 2 categories I created?
 
Each item has a single item slot assigned (0 for right, or 1 for left), so it is not possible to reuse a single item for both hands. In the demo Nolan has a separate item for the left and right hand grenade and pistol. Left and right hand items both refer to the same item type (grenade, or pistol), so you need only a single pickup that refers to the corresponding item type. The possible combinations are defined in the item set manager.
I would recommend studying the demo setup, and trying to replicate to your own character / items.
 
That is a major limitation. Looks like I have to code it in somehow. I don't want to have to create separate Left Hand Swords and Right Hand Swords, or Left Hand Pistols and Right Hand Pistols in the game which would make no sense for the player.
 
This is transparent to the player. Check the demo. The player only sees "grenades" and can equip it in different hands. It's only the configuration which is invisible to the player. You can also just copy the items and change the slot id.
 
Ok, I created left and right sword entries and set them both to Sword item type. I also have Body(for fists) and Long Sword (two handed). When I create three different item sets as Sword-None, None-Sword, Sword-Sword, it works and the inventory count is respected.

But if I use Left Hand Items and Right Hand items for this, inventory count is not respected and even if I pickup one sword, the character wields two swords one of which is not available in the inventory.

Here is my set up for the items main category:
itemsetManagerMain.JPG

Left Hand and Right Hand Items categories:
leftandrightitemcategories.JPG

And the inventory at runtime showing two slots equipped with one item count:
bothareequipped.JPG

As you can see, it shows Sword (Slot 0, 1) with 1 count. How do I make it so that it would only equip Slot 0 if it has a count of 1, and both slots if it has a count of 2 for example?
 
Fixed it by adding this code before availableCount check in ItemSetManagerBase.cs->IsItemSetValid function, inside the for loop, at the end.

C#:
for (int j = 0; j < m_CategoryItemSets.Length; j++)
{
    if (j != categoryIndex)
    {
        for (int k = 0; k < m_CategoryItemSets[j].ItemSetList.Count; k++)
        {
            if (m_CategoryItemSets[j].ItemSetList[k].Active)
            {
                for (int m = 0; m < m_CategoryItemSets[j].ItemSetList[k].Slots.Length; m++)
                {
                    if (m_CategoryItemSets[j].ItemSetList[k].ItemIdentifiers[m]?.ID == itemSet.ItemIdentifiers[i].ID)
                    {
                        availableCount--;
                    }
                }
            }
        }
    }
}
 
Last edited:
Top