Equipping Dual Weapons

Hello Everyone,

I’m currently working on a character, and I was wondering how I could get my character to equip two weapons. I’ve already created a weapon class and attached sockets to my mesh. Where I’m having trouble is getting my character to have two weapons, one in each hand. So, I’ve created two different equip functions in my main, one for the left hand and the other for the right hand. Now, in my weapon class, I have an equip function and this is where I’m checking to see if each hand as a weapon. logically, I thought if one hand is empty, then equipped a weapon, if not, then equipped to the other hand. This is the check that I wrote but it’s not working how I planned in that it only equips to the right hand.
if (Character->RightEquippedWeapon == nullptr)
{
if (RightHandSocket)
{
RightHandSocket->AttachActor(this, Character->GetMesh());
bRotate = false;
}

    }
    else if (Character->LeftEquippedWeapon == nullptr)
    {
        if (LeftHandSocket)
        {
            LeftHandSocket->AttachActor(this, Character->GetMesh());
            bRotate = false;
        }
    }

Remove the “else” in the “else if” statement.

So, I tried removing the else from the else if and now it’s only equipping to the right hand.

are you sure the sockets both exist, and are not in the same place? do you have a pointer to LeftHandSocket?

Yes, both sockets, do exist and I do have a point to LeftHandSocket. I was able to get it working by checking if the RightHand has a weapon if so check to see if LeftHandSocket is valid. Then if RightHand doesn’t have a weapon, then equipped it. But I do have another issue with deleting an instance of the weapon from the world. It seems that when i pick up a weapon, the only one that gets registered is the first weapon, not the second. So, the second weapon never gets deleted if i equip another weapon. Sorry if that doesn’t make sense.