- Home /
Alternative methods to equip items
Hey guys! I'm currently trying to equip a weapon to the player in a 2d minigame. I've searched online on how to do that, and I found two solutions: one is having all the objects in hand and activate/deactivate them (seems like it's common in FPS solutions, where you switch between weapons), the other method is having one public game object per item/weapon, when you need to equip one of them you just instantiate the item prefab and move it to the hand of the player. This seems like the most used method, and I'm probably going for it. However I was wondering.. Are there any other methods? Having one public game object per equipable item seems reasonable while I have very few objects, but in a bigger game with hundreds of equipable items would be confusing and slow, if you have to configure every single item...
Answer by mwaterman29 · Jan 29, 2020 at 06:05 PM
Have you considered making an item class?
You could make an item class with equip/dequip methods where the equip of one dequips all other items in the players inventory.
This would also mean that you can use a list for which items the player has, it seems that in most games of that scale, players never have access to all 100+ items, but just a few, so iteration times would stay low (for example checking which one is equipped by iterating across a List of the players inventory).
Your answer
Follow this Question
Related Questions
Access Inventory from player 1 Answer
Can't find an argument that corresponds to a formal parameter for a function 2 Answers
Button Listener void calling all prefab buttons in scene. 1 Answer
Brackeys Inventory Package, adding icons to empty slots... 0 Answers
Inventory System- Best to Instantiate or Activate equipped items? 0 Answers