Unity RPG Offhand/Shield equipment slot (W/ added Dual Wielding)

,
public void UpdateEquipment()
    {
        var Helmet = equipment.GetItemInSlot(EquipLocation.Helmet) as ArmorConfig;
        var Body = equipment.GetItemInSlot(EquipLocation.Body) as ArmorConfig;
        var Trousers = equipment.GetItemInSlot(EquipLocation.Trousers) as ArmorConfig;
        var Boots = equipment.GetItemInSlot(EquipLocation.Boots) as ArmorConfig;
        var Gloves = equipment.GetItemInSlot(EquipLocation.Gloves) as ArmorConfig;
        var Necklace = equipment.GetItemInSlot(EquipLocation.Necklace) as ArmorConfig;
        if (Helmet == null) EquipArmor(defaultarmorHelmet);        
        else EquipArmor(Helmet);
        if (Body == null) EquipArmor(defaultarmorBody);
        else EquipArmor(Body);
        if (Trousers == null) EquipArmor(defaultarmorTrousers);
        else EquipArmor(Trousers);
        if (Boots == null) EquipArmor(defaultarmorBoots);
        else EquipArmor(Boots);
        if (Gloves == null) EquipArmor(defaultarmorGloves);
        else EquipArmor(Gloves);
        if (Necklace == null) EquipArmor(defaultarmorNecklace);
        else EquipArmor(Necklace);
       
    }

I tried, logically should replace the base armorā€¦ No despawn game object(armor).

And the defaultarmorBody/Helmet/Gloves, etc are all assigned to an ArmorConfig with the appropriate category assigned and an empty armor bject?

1 Like

Thanks, Brian! The reason for the error was simple, I figured it out thanks to you ā€¦ I will delete old videos except this last one(Or should they not be removed?).
I still have a question, but it does not belong to this topic, should I create another one?
Thanks again! And thanks for your time!

Probably best to create a new topic. weā€™ve hijacked this one sufficiently, and itā€™s better if questions are in an Ask category

1 Like

First off, thanks a bunch to Thomas and Brian for this. Iā€™ve gotten this implementation working fairly well at this point, but I need to make adjustments for the goal of my project.

Namely, Iā€™d like to not have to designate specific weapons as ā€œdual wieldā€ but rather allow a weapon tagged as ā€œone-handedā€ to be equipped in either slot, which will allow for dual wielding with any type of 1 handed weapon.

Also, slightly off-topic but Iā€™m having trouble finding a solution for equipping multiple rings using the same enum value. Iā€™m trying to figure out how to do this without using a Ring (Lefthand) Ring (Righthand) method on the rings themselves.

Hereā€™s a quick markup of what Iā€™m going for

Any tips would be appreciated! Happy to post code, but realistically it looks fairly similar to what Thomas has going.

1 Like

Thank you for your question, I know here in this thread we kinda cheese the equipment system to get the results to appear as a ā€œdual-wieldā€ system. Thankfully I address this in my tutorial for the turn-based game course, which is an attempt to integrate the inventory system from the RPG series here.

I essentially create another EquipLocation in the EquipableItem.cs and then slightly reconfigure the MaxAcceptable() method in the EquipmentSlotUI.cs so that if the slot doesnā€™t accept the first EquipLocation then it will check for the second Equiplocation and equip the item. So for the Dual wielding, you just need to make a left & right weapon slot location. You will probably need to do the same for the ring slots.

Hope this helps!

1 Like

I think Thomas may be on the right track with thisā€¦

I did experiment when the Inventory course first came out with ringsā€¦ my solution was less than elegant, as I wound up using

public enum EquipPosition
{
     Primary,
     Secondary
}
Dictionary<EquipLocation, Dictionary<EquipPosition, EquipableItem>>

Then storing everything in the Primary unless it was a EquipLocation.Ring or EquipLocation.Trinket (my own design at the time)
This, of course, required some checking for these corner cases.
Itā€™s not unworkable, I just think I executed it poorly 3 years ago. Probably something to explore again, as Iā€™m working on a build from the ground up rework of the Inventory system for a future tutorial.

2 Likes

Iā€™ll check this out, thanks! :slight_smile:

1 Like

Wellā€¦ I just gave this whole thing a shot. I donā€™t know about the rest of you guys, but the results for me were terrible, so I deleted it off my code

  • Animations were suddenly flipped
  • I can wield stuff where it wasnā€™t supposed to be, in my equipment slots
  • Some unequipped stuff was not de-rendered when I took them off my hands
  • My Cursors got a bit messy
  • My equipment limiter (what stops the player from wielding stuff way above his combat level) suddenly stopped workingā€¦

These are only the bugs I caught from my own testing. The game was basically a buggy mess, so Iā€™ll slowly retry this whole thing and try again to figure out what went wrong, at one point in time

I got things working regarding the dual wield/shield etc. and rings

Thatā€™s after you finished the entire RPG series?

Mm no just core combat and inventory. For your issue with the equipment slots I would double check that the UI slots are set to the correct equipment type in the inspector. Whenever I mess with the equipment type enums those tend to get messed up. I actually have the same issue with the de-rendering weapons, Iā€™ll take a look into that.

After you finish the entire series, the bugs multiply and become a serious problem. I did request @Brian_Trotter to have a professional remake for us regarding this one, now we just have to wait (and probably have a look into it ourselves as well :slight_smile: )

Privacy & Terms