Assign abilities to keys

Hi,
I started to make a game where the character can choose between different abilities, and can pick up them. For example: the character can choose 3 abilities from 5 (can’t pick up more or replace them) and use those 3 like pressing the key 1 and use the 1. ability, pressing the key 2 and use the 2. ability, etc.
But unfortunetly I can’t limit the abilities to 3 because when I pick up an other one that replaces the previous one. and I can’t assign the abilities to different keys.

Just make impossible to pickup after you get to 3. Use and int to count abilities. When it gets to 3, just don’t run the pickup code.

1 Like

Thanks for your answer I was able to limit the number to 3.
But my other problem is that I want to use different keys to different abilities
for example: if I pick up first the fire ability and after the ice ability, than with key 1 use fire and with key 2 use ice, but if I pick up the ice first than the key 1 use ice and the key 2 fire.
I can assign the fire ability to key 1 and the ice ability to key 2 but i want it to depend on the pick up order.
Maybe a little bit confusing, I hope is understandable

What do you currently have? How are you representing the abilities? Arrays or?

( You can show a bit of code ).

This is easy to do, but I might as well get it close to what you already have… :slight_smile:

I used simple boolean variables and branch true/false nods, I know its not the way to do it but thats all I can do.

and with the pick up item I used float to count the abilities and set the boolean true

Ok. I’m assuming the arrows goes with the bullet types ( may not be the case ). Like, you have to fire bullet1 from arrow1.

Then you make an array of the arrows on begin play

and you have an empty array of ‘actor class reference’

image

Then, the pickup just needs to put it’s actor class ( the kind of bullet ) into the array

And firing is

Thank you! It works perfectly

1 Like