How can I swap out abilities? (Super complicated)

How can I use the same key to fire off a different ability depending on which ability I equipped? I would love a large scale solution as I would like to add multiple abilities.

Thanks for your time.

Solution: I have found that using Enums was actually one of the best and simplest ways to implement this. I’m happy I looked into it so thank you to everyone who replied and this is the video I ended up watching - What is an Enum / Enumerator and how do you use it? | Unreal Engine 5 - YouTube

Hey @Shuanlarry! Thanks for posting on the forum, this is a great question.
To start, you could possibly have an array for holding the players’ acquired abilities, and another variable for holding the equipped ability. When you go to “equip” the ability, you set that ability from the array of acquired abilities. Another option could be to look into structs, but it definitely could depend on how you want to implement it.

Hope this can help you out a bit!
-Zen

2 Likes

State Management, State Machines, and the State Design Pattern in Unreal Engine 4 Blueprint - YouTube

you probably find this helpful ^

I use similar idea to handle input states so that one key can do many different things depending on the current state.

I also use similar idea in a simple “gameplay actions” system.

Epic has the gameplay abilities thing but that might be too advanced to start out with. The video above is good introduction for beginner level.

2 Likes

Wow, I actually do have a little experience using arrays but never thought about using them like this. Do you have a video on this by any chance or a tutorial?

Thank you @ZenLeviathan!

Thank you for the video, I don’t understand this enough to apply this knowledge on what I’m trying to do though. Do you have any links to this Ability System?

Thank you @BIGTIMEMASTER for replying.

well it’s the same thing. If you go through the video (maybe you watch it once and then try on your own as you follow a second time), you’ll understand how to apply it.

I’ll give it a try and let you know how it goes. Do you have a link to the ability system though?

try googling “unreal gameplay ability system.”

thats a very robust system. plenty of documentations about it, but i think it’s good to understand the programming 101 stuff first. That way it doesn’t all seem like magic and you can troubleshoot when things don’t work.

state pattern is one of those 101 programming things very helpful to know. it seems complicated at first but once you get it, it saves you a lot of heartache.

I think the first method shown in that video is just using enumerators, which is a very simple approach you can probably understand right away and get started with on your own project. Eventually you realize that may be cumbersome to work with as your project gets more complex, and then the mroe advanced methods come in handy.

2 Likes

If you’re using 4.27, you may want to check the action rpg game template, available for free at epic’s marketplace, which abilities are assigned to a slot index. In this example, only one ability is equipped as default, but the built-in system allows expansion to more slots by editing the combat widget. So, whatever ability is equipped from the “store” menu, it will be activated by that mapped input logic triggered from the player controller. A function “activate ability at slot” is available in this game sample.

3 Likes

Thanks a ton I’ll look into this as well probably tomorrow.

1 Like

Glad to know. Keep in mind that template is a ready-to-ship, single-player game, and a very useful learning resource. Good luck in your project.

1 Like

Thanks!

2 Likes