I’m horrible at arrays but I hope this might be a chance to truly learn how they work.
What I want is to create an inventory system similar to how you handle weapons in an fps. I’ve already created the script to pick an item up, making the item “equipped” and “accessed” through booleans. Accessed means the player owns the object and can choose to equip it. Equipped means that it’s the item that the player is currently holding.
I also have animations that will play whenever the player equips weapons and unequips them. And all the functions and stuff are pretty much finished as well.
But now I need some lines of code that makes the game skip the items that are not accessed yet so that when I use the scrollwheel to go through the items I will only equip items that I have access to and not the ones I am yet to encounter. I’m thinking maybe some loop searching through an array or something.
I guess the order of the events would be: Scrollwheel up/down → if(itemcount > 2) { → Unequipitem(); (Which includes the unequip-animation, yields everything until the animation is finished and then hides the weapon using a layer-switch) → The loop to search for the next weapon → When it’s found use Equip(item); (item would be the name of the item to be equipped (or maybe a number could work as well))