> For the complete documentation index, see [llms.txt](https://docs.febucci.com/text-animator-unreal/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.febucci.com/text-animator-unreal/customization/create-your-own-effects/writing-custom-effects-blueprints.md).

# Writing Custom Effects (Blueprints)

Other than using built-in effects and creating custom ones from the Editor, you can easily program custom Effects via Blueprints.

***

## Effect Base Class <a href="#id-1-effect-base-class" id="id-1-effect-base-class"></a>

All you need to do is select the base class `UAnimationEffectBase` when creating a new Blueprint.

<figure><img src="/files/evAuGXNSAHJNMXFyJK4o" alt="" width="563"><figcaption></figcaption></figure>

There are also some useful classes already available for you that you can view from the API, like the `UBehaviorEffectBase` or `UAppearanceEffectBase` which are intended for each effect category, `UBehaviorEffectSine` which already handles modifiers such as “a, f, w” and more.

***

By creating a BP from `UAnimationEffectBase`, you’ll find some methods to override, and in the docs (both Scripting API and in IDE) you’ll find more examples and info about new ones as well.

{% hint style="warning" %}
**Remember:** Blueprints can implement C++ functions as both Events and Functions. While these can be sometimes interchangeable, Functions are required when there's a return value (GetMaxDuration) or a parameter has to be returned as reference (ApplyEffectOnParseTo/ApplyEffectOnFrameTo), while Events are typically quick no-return notifications (ResetContext).
{% endhint %}

## Modifier Methods <a href="#id-3-modifier-methods" id="id-3-modifier-methods"></a>

Since effects can be affected by “[Modifiers](about:/text-animator-unity/docs/how-to-add-effects-to-your-texts/#modifiers)”, you can override the following methods to handle them in your animations:

These methods will be applied, in order, before the animation.

### ResetContext <a href="#id-31-resetcontext" id="id-31-resetcontext"></a>

<figure><img src="/files/Y48XjgwQMxOglh48m8Hg" alt=""><figcaption></figcaption></figure>

You can use this method to reset your animation’s variables to their initial state.

For example, you could have a variable called `BaseSpeed`, but in your effect only use another called `CurrentSpeed` and have that variable be `CurrentSpeed=BaseSpeed` inside this method.

### SetModifierTo <a href="#id-32-setmodifierto" id="id-32-setmodifierto"></a>

You can use this method to apply a modifier to your variables.

For example this will multiply the `CurrentSpeed` value by the `s` modifier (if there is any).

<figure><img src="/files/WlSrFzg2My8nFjzGhRx1" alt=""><figcaption></figcaption></figure>

👍🏻 If you want to create a Behavior effect that has three modifiers such as “amplitude”, “frequency” and “waveSize”, you can create a Blueprint that inherits from `BehaviorEffectSine` which will handle them for you.

## Animation Methods <a href="#id-4-animation-methods" id="id-4-animation-methods"></a>

Here are a few methods that you can override to create your custom animations.

<figure><img src="/files/Tovf0zF9zWityqw7fhN4" alt=""><figcaption><p>Go to "My Blueprint" panel, then click on the "Override" dropdown and select the method you want to override</p></figcaption></figure>

### GetMaxDuration <a href="#id-41-getmaxduration" id="id-41-getmaxduration"></a>

<figure><img src="/files/3VpLPHBAEzJLkquvU9Pw" alt=""><figcaption></figcaption></figure>

The max duration of the effect. This is used to calculate the total duration of an animation and have smooth transitions, but if you have an effect that never ends you should return -1.

### CanApplyEffectTo <a href="#id-42-canapplyeffectto" id="id-42-canapplyeffectto"></a>

<figure><img src="/files/ePxjzy6AV9WSFBfyIS13" alt=""><figcaption><p>Example: only apply the effect if the glyph is a number</p></figcaption></figure>

Used to check if the effect can be applied to the current letter. For example if you’re creating an appearance effect, which only applies if a character passed time is within the effect’s duration (but in that case you can create a Blueprint from “AppearanceEffectBase” and have it handle that for you).

You can go beyond that, for example check if the character is a number or a letter, or their word index and much more.

### ApplyEffect Methods <a href="#id-43-applyeffect" id="id-43-applyeffect"></a>

When you override these methods you will be asked to convert them into a function to allow for a return value.

{% hint style="warning" %}
**Remember:** to convert an Event to a Function, simply right click on the event node and select "Convert Event to Function".
{% endhint %}

Both methods have the `Glyph` argument. It holds all the information about each single character. It's passed by reference, which means you can directly modify it.

#### ApplyEffectOnParseTo <a href="#id-43-applyeffect" id="id-43-applyeffect"></a>

<figure><img src="/files/yQmkuPJMukdlXp9lgJqs" alt=""><figcaption><p>Example: make all glyphs bold when the effect starts</p></figcaption></figure>

One-time function called when glyphs are first created.&#x20;

It is useful if the effect has to perform one-time logic on the character, like initialization, or logic that is wasteful to perform each frame, like applying a style such as bold.

#### ApplyEffectOnFrameTo <a href="#id-43-applyeffect" id="id-43-applyeffect"></a>

<figure><img src="/files/K7cvG45qZtUwKrhSZSQO" alt=""><figcaption><p>Example: make the glyph move up or down following a sawtooth!</p></figcaption></figure>

Main function to apply an animation to a letter, called if `CanApplyEffectTo` returned true and executed once per frame.

It is useful to animate each `Glyph`, for example, you may update its `Glyph.Offset` to move it around.

## ✅ Done! <a href="#done" id="done"></a>

**You’ve completed all the steps necessary, yay!**\
The more effects you add, the more this process will sound familiar and simpler.

{% hint style="warning" %}
Remember to create your effect `UDataAsset` (yes, you can create Data Assets from Blueprints since they are nothing more than a class) in the Content Browser, and add it to a database.

You can read more here: [Databases](/text-animator-unreal/effects/add-effects-to-your-texts/databases.md)
{% endhint %}

{% hint style="info" %}
👍🏻 You can always take a look at the Extra content to see an example of Blueprint customization!
{% endhint %}

**Have fun applying your effects!**
