I have an inventory system I made. I added options for items to be able to be “Used” “Eaten” and “Equipped” and the method I’m using to add all those options is saying “can you use it?” if not then ask “can you eat it?” if not then “can you equip it?” and so forth. Would there be different way to do this other than nesting with branches like this?
Photo of BP
You can set an Enumerator with all those characteristics and Switch on Enum.
Or if all those variables are bools, you can create an array out of them and do ForEach loop to see what’s true.
It would still result in me doing branch after branch checking. if one is true or false and if its false then check the next one
Well yeah, either way. If you want to check three values, there’ll always be some branches. Alternatively, if an object may only have one of those true, set a single interface that will call the needed function. Then you send a message, and the object does what it can, no checking needed.
I added the Enum to the structure, this seems the best way. but is there a node that allows me to execute a different path if it is equal to one thing vs the other
if backpack to down path a,
if weapon go down path b,
if armor go down path c,
with each path being like a branch but with multiple nodes other than “true” and “false” or would I end up having to do multiple branches for each enum var?
I wouldn’t be able to use an interface as far as I know. the “items” are a structure with all of the item info in it stored in an array. I don’t think I could use an interface there.
im getting the info from one of the elements in that array and breaking the structure to get the info on how to equip the item.
Thank you so much! both of you guys. this is the node I needed.
This is much appreciated!
Edit: This is so much easier to manage and find parts rather than using branch after branch
yes, whenever you create an Enum, ue creates a switch for you for that enum.
So, in this case i created an enum called ItemType, with 3 options. This is what the “Switch on ItemType” looks like.