How can I equip and switch weapons from existing Inventory?
So I have a crafting system for the game project I am making and it has a very basic inventory system that shows what was added after being crafted on the crafting system by showing it on the ui but, the inventory is not actually visible so it remains hidden to function in the background to hold and get stuff from.
I am trying to figure out how can I equip/unequip weapons onto my character from it after they are created in that crafting system to hold and use or shoot with and such?
So far I found this https://www.youtube.com/watch?v=XCMjn2sFGzQ which seems to be fairly close but, I am not very sure if that'll help me figure it out better so I am currently following along on the tutorial until I get to this point to try to figure it out better. I have also tried looking around to research it further but it's been three weeks now and I am still pretty clueless.
Does anyone have any advice about this that could point me in the right direction? or something similar?
it depends much on how you want your invertory system to behave, but overall, that's the generic case:
your character has to have a self-made reference "current_equipment" of class "Equipable" (you make this one), and any time you "activate" an equipment from your invertory - you set "current_equipment" to point to this item, and hide the previous "current_equipment" (visibly, stick to belt / pocket, or however you want it (abstractly hide)). rest is animations and game-specific tweaks you shall figure out. let me know if you mess something up, along with more specific details, so i can help you out :)
oh and each item you might want to equip, has to be of a class that inherits Equipable, so "current_equipment" can compatibly point to that.
example: class Hammer class Equipable
Follow this question
Once you sign in you will be able to subscribe for any updates here