Madboy James
Member
Hi, I have a use case where I want an ability to give a weapon to the player.
I want to use this pattern for all sorts of equipment (grenades, drones, throwing knives, special heavy weapons, ect.) but right now I am trying to get a grenade to work.
I have an ability that calls inventory.AddItemIdentifierAmount() followed by inventory.EquipItem() to grant the player a single use grenade weapon with a 10 second recharge.
When the grenade is used, or if the ability is canceled by pressing the ability key again, I call inventory.UnequipItem() followed by inventory.RemoveCharacterItem() to remove the grenade from the inventory. I then call inventory.EquipItem() with the character's previously equipped item to give them their gun back. This, for the most part, works.
The issue arises when the player tries swap weapons while holding the grenade. If swapping to previous, I can catch the unequipped event and remove the grenade. If swapping to next, there is no unequipped event, and the player shows a "grenade pull out" animation and equips the grenade which they were already equipping... then things break when trying to swap back to the player's gun. (also, when the grenade is initially equipped, the animation does not change. The grenade is held as if it were a rifle, with no pull-out animation or anything. I have immediateEquip set to false.)
I looked more into the inventory, EquipPrevious, EquipNext, and EquipUneuip classes... and I wonder if I am doing this right, and if there is an already established way to accomplish what I'm trying.
Any help would be appriciated.
I want to use this pattern for all sorts of equipment (grenades, drones, throwing knives, special heavy weapons, ect.) but right now I am trying to get a grenade to work.
I have an ability that calls inventory.AddItemIdentifierAmount() followed by inventory.EquipItem() to grant the player a single use grenade weapon with a 10 second recharge.
When the grenade is used, or if the ability is canceled by pressing the ability key again, I call inventory.UnequipItem() followed by inventory.RemoveCharacterItem() to remove the grenade from the inventory. I then call inventory.EquipItem() with the character's previously equipped item to give them their gun back. This, for the most part, works.
The issue arises when the player tries swap weapons while holding the grenade. If swapping to previous, I can catch the unequipped event and remove the grenade. If swapping to next, there is no unequipped event, and the player shows a "grenade pull out" animation and equips the grenade which they were already equipping... then things break when trying to swap back to the player's gun. (also, when the grenade is initially equipped, the animation does not change. The grenade is held as if it were a rifle, with no pull-out animation or anything. I have immediateEquip set to false.)
I looked more into the inventory, EquipPrevious, EquipNext, and EquipUneuip classes... and I wonder if I am doing this right, and if there is an already established way to accomplish what I'm trying.
Any help would be appriciated.