Auto Unequip Weapon

Thank you sir, i've tried using the API script, and now when the game starts the character automatically does the unequipp animation and stores his sword in it's holster. However, after it happens, i can't equip the sword again, it's still available (i do see the sword in his holster), but i can't unsheath it again.

Isn't there another approach to achieve this ? I mean, instead of making the character unequipping the sword at beginning, how could we manage to make the game start with the item directly Unequipped ?
After searching, i found that there are stateindexes that stores the Equip and Unequip states

Equip Item State Index : 4
Unequip Item State Index : 5

Isn't there a precise spot where a "Game starts with Item State Index 4" is stored that we could modify it to 5 ?
 
Those Equip/Unequip item state indexes are just for the animator controller to use.

The inability to re-equip the item after manually firing EquipUnequip does seem to be an issue. However, there is a reasonable work-around:
- Adjust the 'Auto Equip' value in the 'Equip Unequip' item ability so that the sword is not equipped by default. This page describes each setting in more detail.
- The first time the user equips the item, manually fire the EquipUnequip ability, passing in the sword's ItemSet index. In the demo scene, this is 8, so you'd call StartEquipUnequip(8).
- From this point on, the user can toggle equip as normal.
 
This is really weird... I've tried to check Nothing in "Auto Equip" and use the script to pickup the sword without equipping it, but the best thing i could ever make with it is either the sword is already equipped at start, and i cannot put it back with T, or it is unequipped at start but i can't pull it out with T...
I've tried the script given to me in this topic, and ever the API script in "Equip/Unequip" documentation uh
 
After adding the Pickup script and left the Inventory default loadout blank, when the game starts the script adds the sword and then it gets automatically equipped (meaning unsheathed). And if i check "Nothing" on the Auto Equip part of EquipUnequip ability, when the game starts it gets almost perfect, the sword gets created, and is stored in its holster, But then i simply can't equip it with the T hotkey. it's like the object is created and stored in the character's inventory, but the character gets forbidden to unsheath it.
UnequippedButExists.png

Edit : I did it !! I also installed a script named Equip along with the Pickup one, and set True on the
"ImmediateEquipUnequip" statut line.

For those who would like to achieve this too :

On your Character Locomotion component, find the -Equip Unequip- ability. Inside it, you have to choose -Nothing- on the "Auto Equip" tab.
After this, add the Pickup script, and the Equip script from the documentation : Inventory

On the Equip script, on the line 32 :
Code:
equipUnequipAbilities[i].StartEquipUnequip(m_ItemSetIndex, true, false);
Change the second "false" to a "true".

Then, after inserting those scripts on your character, on the components fill up the tabs with the corresponding elements and there you go !
 
Last edited:
I guess that it'll never be over ahah...
I have absolutely no clue how nor why, but even if it perfectly works now, when i make a build of the game and launch the build, the sword gets equipped... And wait for it, after making a build, THE SWORD gets equipped on the editor too ! Holly molly, nothing has changed, the Pickup and Equip scripts haven't changed at all, everything is fine but it doesn't work after a build.

The "funiest" part of this ? If i delete the pickup and equip component, delete the scripts and install those scripts again... It works again lol until the next build. How is that possible ?

The build gets me a succeed message on the console, and there are 0 errors nor warning concerning that issue
 
Maybe the cause is related to your project only. I have done that “auto unequip” easily in my project and demo scene.
Did you check your code line-to-line by Unity Debug functions?
 
Okay i think i definitely made it uh...
I created the scripts again to make it work and it did, and then on Build Settings, i changed from x86 to x86_64, and don't ask me why but everything worked perfectly after that, the changes are saved after building the game and playing it x)

Thank you very much for everything guys :D
 
Top