Ability Examples

In this section we will look at examples of existing abilities and explain how they work.

#1 Ability_Player_InstantHeal

This ability plays anim montage and heals owner once for specified value.

It doesn't override event Pressed, so it doesn't care whether ability input is being pressed or not.
Instead it observes if ability input is released, then it tries to start ability using function from AbilityComponent, if return value was true, then it plays ability montage.

Heal Montage has ANS_AbilityEffect_WithFinish notify in it.

When this notify Begin event is triggered, it calls AbilityEffect function from AbilityComponent.

AbilityEffect function in turn is calling ReceivedSpawnEffect function from ability, which heals the owner, spawns particle, plays sound and consumes mana.

And when End event of notify is triggered, it calls EndAbility function from AbilityComponent which means that ability was successfully finished.

#2 Ability_Player_DrainHealth

This ability is a bit more complex.
On hitting enemy it drains his health and gives it back to owner.

On pressing Ability input, it tries to cast, but if it fails then sets a timer which will continue to attempt, until ability is Released or Ends.
This way if ability was pressed for example during Rolling, it will start casting automatically without need to press input again right after it ends rolling.

Montage used by this ability is divided into 3 sections

  • Start
  • Loop
  • End

On ability Pressed it is played from Start and remain in Loop section.
On ability Released or End montage is played from section End.

During the montage, notify AbilityEffect is calling function with same name from AbilityComponent which in turn is calling ReceivedSpawnEffect function from ability.

Event ReceivedSpawnEffect is setting EffectEnabled variable to true, then spawning beam particle and sound.

Then Event Tick updates effect (its transform), consumes mana, and checks whether there are any enemies hit by this ability.