Ability Component

AbilityComponent is the intermediary between character (player or AI) and Ability (spell).
It watches the state of the owner and ability, if ability is casting, if input is pressed, recently used ability anim montage, ability effect transform etc.

So when the owner is pressing or releasing Ability input, it doesn't call directly events from Ability blueprint, instead it calls functions from AbilityComponent, which in turn informs about it Ability itself.

Usefull variables

  • CurrentAbility - Currently stored Ability
  • IsPressed - whether Ability input is pressed or released
  • IsCasting - whether Ability is currently casting
  • RecentlyPlayedMontage - last anim montage used by Ability
  • UpdateEquipmentAbility - whether Ability should be automatically updated based on item equipped in EquipmentComponent

Usefull functions

  • AbilityPressed - sets variable IsPressed to true and informs Ability about it
  • AbilityReleased - sets variable IsPressed to false and informs Ability about it
  • AbilityEffect - informs Ability that it should spawn an Effect
  • StartAbility - checks whether Ability can be casted, then sets variable IsCasting to true
  • EndAbility - sets variable IsCasting to false and ends Ability
  • UpdateAbility - updates currently stored Ability
  • PlayAbilityMontage - plays montage on owner character mesh and stores it in variable
  • StopAbilityMontage - stops playing Ability montage

Function EndAbility takes parameter of type E_AbilityEndResult to determine the reason for the ending of ability.

  • Finished - ability has succesfully ended casting
  • Interrupted - ability was interrupted e.g when owner gets stunned
  • Canceled - ability was canceled by owner
  • OutOfMana - there was not enough mana to keep casting ability
  • Destroyed - ability has been destroyed

AbilityComponent is also responsible for Spell Indicator (green indicator on the ground showing ability location).

  • ShowSpellIndicator - shows spell indicator, takes material and radius as parameters
  • HideSpellIndicator - hides spell indicator
  • UpdateSpellIndicatorLocation - updates current location of spell indicator