Best way to toggle equipped weapon for a short while.

grkwasniewski

New member
Hi all :)

I have this scenario that I want to cover:

  1. The Player has a weapon equipped - let say it's in item set == 0
  2. The player tries to pick up some game object - for this example let's say it will be a simple barrel. I have a separate script for that.
  3. When the Player pickups the barrel, the currently equipped weapon should be disabled (preferably unequipped).
  4. Currently I'm using Item.StartUnequip() and Item.StartEquip() BUT...
  5. To throw a pickup barrel Player uses the left mouse button. After the barrel is thrown, the weapon is reequipped AND it fires a single shoot (which thing I don't want). Even if I add the delay for the Item.StartEquip() the weapon will still fire a shoot.

Is there a better way to temporarily disable the currently equipped weapon or maybe I just need to update my current logic?
 
Yeah, I have already tried that (fragment from my implementation):

C#:
var equipUnequipAbilities = _characterLocomotion.GetAbilities<EquipUnequip>();
        int itemSetIndex = 0;
        if (equipUnequipAbilities != null && equipUnequipAbilities.Length > 0)
        {
            for (int i = 0; i < equipUnequipAbilities.Length; ++i)
            {
                if (equipUnequipAbilities[i].ItemSetCategoryIndex == 0)
                {
                    equipUnequipAbilities[i].StartEquipUnequip(itemSetIndex, true, false);
                    return;
                }
            }
        }

But every time executions stops in this block (inside EquipUnequip method)

C#:
// No actions are necessary if the item set is already equipped.
            if ((!IsActive && itemSetIndex == m_ItemSetManager.ActiveItemSetIndex[m_ItemSetCategoryIndex]) ||
                (IsActive && itemSetIndex == m_ItemSetManager.NextItemSetIndex[m_ItemSetCategoryIndex])) {
                return false;
            }

Also, this comment is very misleading - // No actions are necessary if the item set is already equipped.

It would indicate that method can only equip the item.
 
If you want to unequip your ItemSetIndex should be -1. If it is returning false at that line then it means that the ItemSet that is already active so there isn't anything for EquipUnequip to do.
 
Top