Toggle equip specific item

matmalm

Member
Hi, I have a default loadout item which I'd like to toggle equip/unequip.

This default loadout item shouldn't be mix with pick up items. So, in order to equip/unequip this item I'd like to press a single key, but would not like to mix it with the items I could pick up, meaning that if I press "Equip Next Item" or "Equip Previous Item" only the items I had previously pick up would appear. But this particular item only should appear with a toggle key.

As an example: let's say it's a paper map. So this map is a loadout map the player always have with him, but for the player to see this map he has to press a key, and to put the map away he has to press the same key.

Is there a built in ability item to do this?
 
You could create a new slot and ItemSetCategory that only contains your single item. From here you wouldn't add the Equip Previous/Next abilities and only the toggle ability. This will allow you to only equip the single item with a button press and not the standard buttons.
 
You could create a new slot and ItemSetCategory that only contains your single item. From here you wouldn't add the Equip Previous/Next abilities and only the toggle ability. This will allow you to only equip the single item with a button press and not the standard buttons.
Thanks!
Edit: I can't find a way to disable one category, when the other one is active, and vice versa.
When I toggle the item which is in another slot and another category, the first category (where the body and pickup items are) is still active, so the player holds 2 items at the same time.
 
Last edited:
Not directly, but you can use the state system to enable/disable the abilities which correspond to the category.
 
Not directly, but you can use the state system to enable/disable the abilities which correspond to the category.
Could you explain it a little bit further?

I have a state on Equip Unequip ability to disable the other Equip Unequip ability, but have many issues:

- When I pick up an object, it does pick it up but I can use Equip Next/Equip Previous, even though the corresponding Equip Unequip is enabled.
- The character have 2 default loadout items, "Body" and "Case", but it starts with both "Body" (slot 0) and "Case" (slot 2) active, meaning that even if I toggle "Case", body is always active.
- Also when I pick up an object, even though the "Case" is inactive, it becomes active.

The other way I'm trying to achieve it without disabling the abilities, is to disable the item set when one item is active. In this case for "Case Rule" state to disable "Body" and all of the pickup items, and vice versa. However, "Case" is disabled the player can't toggle it, then when the player picks up an item, the "Body" becomes disabled, which I have no idea why the last one happens, as I have an item preset on the "Case" to the disable the "Body" Item Set.

As a feedback, it's not very intuitive. It's been too complicated to achieve something that is relatively simple, or it's just me, I don't know.
 
Last edited:
Take a look at the melee section of the demo scene. Within that section we disabled the shootable weapons from being able to be equipped using the state system. Now that I see it, we did it by disabling the item set and not the ability. I think this route makes the most sense for your use case as well.

As a feedback, it's not very intuitive. It's been too complicated to achieve something that is relatively simple, or it's just me, I don't know.
It may seem simple, but this is actually something that is pretty deep within the featureset. The ItemSet system can get pretty complex.
 
Take a look at the melee section of the demo scene. Within that section we disabled the shootable weapons from being able to be equipped using the state system. Now that I see it, we did it by disabling the item set and not the ability. I think this route makes the most sense for your use case as well.


It may seem simple, but this is actually something that is pretty deep within the featureset. The ItemSet system can get pretty complex.
By shootable weapons you mean the AssaultRiffle and the Pistol? Because I can equip those in the demo scene under the melee section.

The documentation is also very vague about this. I have spent many hours trying to do different combinations with no close to good results. I don't understand how this can be so complex, but it should be intuitive as I'm not trying to insert something completely new to the game industry.
 
Did you try a fresh project? I just tried the demo scene and was not able to use the pistol or assault rifle in the melee section.

This is mostly related to the state system so once you have an understanding of that the rest should be easier. On the item set you will disable it when a particular state is active. With the demo scene that state is the melee section. In your case you could do it when another item is equipped.

1732690927111.png
 
Did you try a fresh project? I just tried the demo scene and was not able to use the pistol or assault rifle in the melee section.

This is mostly related to the state system so once you have an understanding of that the rest should be easier. On the item set you will disable it when a particular state is active. With the demo scene that state is the melee section. In your case you could do it when another item is equipped.

View attachment 13404

Yes, new project: Unity 6000.0.28 URP. Just imported Opsive with the URP integration, nothing else.
meleeufps.png

Is the demo scene that comes inside the Package Manager? Unless there is another package/integration?


For a start, how could I just enable 1 category when player spawn (body), and then being able to toggle the other category (without body being active)?
 
Last edited:
I managed to do it. The only issue is that when entering play mode, I'd like to have 1 default loadout equipped, but both (I have 2 default loadout items) are equipped. Both are equipped, even though there is one in red. When pressing the toggle ability, it works normal with the toggle. It's only when entering play mode.
 
The demo scene throws errors with URP and that could be causing other issues. For a proper test you should use built in.

For a start, how could I just enable 1 category when player spawn (body), and then being able to toggle the other category (without body being active)?
You said that you figured it out, but you can use the state system for this. On the ItemSet there is a state field (with the value of AssaultRifle in your screenshot) that you can then use to disable other states. This is similar to how the demo zone works, except instead of the state name being set on the ItemSet it is set within the trigger zone. That state is named DisableShootableItemSets.

This method will also ensure only the correct ItemSet is equipped.
 
Back
Top