OVERVIEW:
The system 2nd core Component is the ability manager component. similarily to the state manager component, it has a basic functionality that is done just like the state manager component. if this is the case, why do we have a whole new component ? The answer to it is simple, just like i explained “Attacking” in the state manager component section, Attacking is very broad and because of that we need to specify more down the road the “type” of attack we will be performing, and this is where the ability system component shines. A More specific type of attack. usually, abilities fire within the state it self. so SOME states you have will require different types of abilities to run. there is also the type that doesn’t require any ability to run, an example would be walking or sprinting. those are states but don’t have any abilities associated with them. why ? because walking is walking, nothing else to it right ? so, some states need abilities and this is where ability system is handy, but in the same time, some don’t require any.
FUNCTIONALITY:
The ability components keep a record of all the abilities that can be fired at any given point. with that in mind, they will always remain in an array all the time. and only ONE can be active at any given point, so do your programming with that in mind. Additionaly , you have the passive abilities, which is another array of abilities that need to exist and active but nothing that effects “visual” representation like a montage/ animation playing. you can think of them as “buffs” that grant you more power, but dont provide more “animations”. in summary, you can have ONE active ability but MULTIPILE active passive abilities.
There are 2 main functions in it:
Try Perform Ability Of Class:
this function will fire given that you provide it with the appropriate class, with this function there is an option with condition check, this will be explained in the “Base ability Object” section.
Perform Ability of Class:
just like the above function, the only difference is that it doesn’t require a condition to fire:
————————————————————————————————————————————————————-
Base Ability Object:
see from the “BP_BaseAbility” that all Abilities inherit from. The most important functionality in it relies on those specific functions shown below:
Construct Ability:
This function gets called when you construct the Ability for the very first time, an example would be when you equip a new weapon. with the sample provided, every weapon you attempt to equip ( whether its on begin play or on overlap ) will have a specific “data asset” associated with it. That Data Asset has “Abilities” that can fire when the specific weapon gets equipped. once that data asset is registered. all the Abilities within it will be constructed, and that’s when this function will fire, so any variables you think you might use in that ability can be saved on construction of that ability.
Start Ability:
From it’s name, it will call this function whenever the state starts. most abilities from the player fire within states from the inputs the player triggers during gameplay, you can refer more to the provided “Attacking State” to see how to trigger it.
Tick Ability:
this one is extremely important as it runs on tick, please note that this function ONLY fires if the ability is ACTIVE. meaning, if you have multiple abilties registered, none of the tick functions will fire unless its active, and only ONE ability is active at any given point.
End Ability:
This function fires when a new ability gets called. for example, if you have an Equip ability and a light attack ability. the moment attacking gets called, it will attempt to end the ability that is active BEFORE the new attacking ability starts.
Can Perform Ability:
this function gets called when the developer calls the “Try Perform Ability Of Class” from the ability component. if you have the condition set to true, this function will get called.
All the provided Functions can be overridden from blueprints, so you can create any type of behavior if you keep the notes above in mind