Weapon pickup and inventory?
How can I make a weapon that I can pick up and then have multiple weapons in a inventory?
asked Aug 04 '15 at 02:40 AM in Blueprint Scripting
A simple way to do an inventory (not the best way, mind you) would be to make an array of a variable type. The size of the array and the number of arrays you may need would depend on how you want this inventory system to work. If you wish to do something similar to an FPS like Doom or Unreal Tournament, you could have an array with about 10 booleans. If you want to get more fancy, you could make a struct or class for the weapons themselves that can store things like ammo or durability, instead of using booleans. Each boolean could be associated with a weapon and be set to true or false depending on if the character has it. You could then have keybindings set up for 1-9 on your keyboard and if a user hits a button, check to see if the boolean for that weapon is true. If it is true, then equip the weapon associated with it.
As far as the pickup goes, you could make an asset that sits on the ground (or floats, it's up to you) with a box collision surrounding it to act as a trigger. Turn all collision off but allow the trigger to overlap pawns. After this, you could use 'OnBeginOverlap' on either the Pawn or the asset itself to set the boolean in your array that is associated with that weapon to true and then run DestroyActor on the asset.
Hope this helps!
answered Aug 04 '15 at 02:57 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here