> 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/extra-customization-via-c++-blueprints/writing-custom-actions-c++.md).

# Writing Custom Actions (C++)

Other than using [built-in actions](https://docs.febucci.com/text-animator-unity/typewriter/wait-actions-when-typing), you can write your own via script (C++).

***

{% hint style="warning" %}
Remember to add the Plugin module to your Project dependency to extend any Plugin class [Best Practices](/text-animator-unreal/other/best-practices.md#extending-plugin-c-classes)
{% endhint %}

## Actions Base Class <a href="#actions-base-class" id="actions-base-class"></a>

When creating a new class, inherit from `AActionActorBase` defined in "ActionActorBase.h"

```cpp
UCLASS(Blueprintable)
class ACustomAction : public AActionActorBase { ... }
```

### DoAction Method <a href="#doaction-method" id="doaction-method"></a>

Then, all you need to do is overriding the “DoAction” method and write your code inside it.

Remember that actions **pause** the typewriter until they’re completed (for example, waiting for player input or until time has passed).

```cpp
void ACustomAction::DoAction_Implementation()
{
    // [...]
    // Use inherited and already initialized variables:
    // FActionMarker ActionMarker
    // UTypewriterCore* TypewriterRef
    
    // At the end always call TypewriterRef->CompleteCurrentAction()
    // to resume the typewriter
}
```

* The `ActionMarker` inherited variable has useful info about your tag, for example the ID or if there are any parameters that come with it (e.g. `<playSound=02>`).
* The inherited `TypewriterRef`  references the component that is currently performing the action. It contains all relevant information about the current typing status.

{% hint style="warning" %}
**IMPORTANT!** Remember to call `TypewriterRef->CompleteCurrentAction()` once your action is finished, as shown in the snippet, to signal the typewriter to resume typewriting, or it will be left stuck in pause.
{% endhint %}

## Action Object Base Data Asset

To effectively use your Custom Action you need to create a Data Asset that uses the newly created C++ class.&#x20;

To do so, go into your Content Browser->Miscellaneous->Data Asset->Action Object Base.&#x20;

<figure><img src="/files/YY37pcWcdPpSCJ45Ws2h" alt="" width="563"><figcaption><p>Newly created Custom Action Data Asset</p></figcaption></figure>

* `Tag ID`: is the string you will use inside your "**Animated Text Block**" to trigger your action.
* `Action Actor Class`: is the actual C++ class extending `AActionActorBase`.

{% hint style="info" %}
Remember to add this newly created Data Asset to the proper database in your "**Content/Plugins/TextAnimatorFebucci/Data**" folder
{% endhint %}

***

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

Done! With this simple procedure, you can add any Custom Action you want.
