InventoryItemSetManager Rules + EquipNext

airoll

Member
Hello, I currently have an InventoryItemSetRules object that has one category set rule:
  1. Equip a Weapon to Slot 0
  2. Equip a Shield to Slot 1
When I start the game I have a loadout with 2 weapons and 1 shield, it generates a set of item sets like the following:
  1. Weapon A / Shield
  2. Weapon B / Shield
  3. Weapon A / None
  4. Weapon B / None
I want to be able to cycle between (1) and (2) such that my shield is always active and equipped. If I use the ability EquipNext, then I notice what happens is that it will equip the next item set to (3) and (4), which have the shield unequipped. What's the best way to handle this? Create a new ItemSetRule that won't generate (3) and (4)?
 
There are multiple ways to go about this, as you said one of them is to create your ItemSetRules in a way that won't create 3 and 4. But what if you don't have a shield? Then you wouldn't be able to equip any weapons.

You could create a custom Item Rule Object, It's useful for very complex setups, but that would require a fair amount of code and understanding of the Item Set Rules system.

So what I would recommend is use the state presets.
1630914992672.png
You can create a state preset that sets "Enabled" and "Can Switch To" to false when a certain state is active. It could be the state of the ItemSet with a shield is equipped (i.e "SwordShield" for the snapshot above) or it could be a state that you assign externally using a very simple line of code:
Code:
var stateName = "MyState";
var activeState = true;
m_CharacterLocomotion.SetState(stateName, activeState);

You can learn more about state system and presets here: https://opsive.com/support/documentation/ultimate-character-controller/state-system/

I hope that helps
 
Top