I've searched throughout the internet and the forums but all I found was switching between a weapon you have and one on the ground.
Basically I'd like to know how can I switch between 2 or more weapons I already own, simply by clicking 1 or 2, or scrolling the mouse.
So for example, I spawn with a pistol, and when I click 2, assuming I have the weapon, I switch to a shotgun.
asked Aug 15 '16 at 08:12 PM in Blueprint Scripting
If you want to switch between two or MORE weapons then you can use an Array within the Player blueprint. (UPDATE 2: This will work if you use the mouse wheel to switch or a button that must be pressed each time you want to switch.) Call this array you create EquippedWeapons and make the type as the MasterWeapon blueprint or the main weapon blueprint you used to create all of the child weapons from, but make sure it is of its class, not references.
UPDATE: If you want to make it even easier on yourself in the future, you can even make a new Component to attach to your player that does all of this for you, and set events to communicate with the component; and on Begin Play you can have your save function load the information into the component. If you want some help with this let me know and I can elaborate a bit more on the Component aspect.
Simple answer, yes you can.
You'll need the two weapons, a weapon swap animation (or possibly split into two), an input event (button binding) for swapping weapons, and a boolean variable for PrimaryWeapon or something of that nature.
The basic idea is that on Input Event - SwapWeapons, you check your boolean to see which weapon is currently equipped, then hide that one (or toggle vis on it and a currently-invis mesh somewhere on the body) and turn off its functionality, while doing the opposite for your unequipped weapon. It's really not super difficult, but you're right in that there isn't a lot of documentation or tutorials on the topic.
Follow this question
Once you sign in you will be able to subscribe for any updates here