# Creating a component

This page explains how to create a new component for Motion to extend Motion to your needs. In this example we will create a *Health Component* which adds a Health value to the Motion Character which we can then use to implement **fall damage**.

### Creating a Motion Component

To begin, we need to create a new [Actor Component](https://docs.unrealengine.com/en-US/API/Runtime/Engine/Components/UActorComponent/index.html) by right-clicking in the [Content Browser](https://docs.unrealengine.com/en-US/Basics/ContentBrowser/index.html) and selecting **Blueprint Class**.

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

In the modal that opens, scroll down and select **BP\_BaseCharacterCurvedComponent**.

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

Name it **BP\_HealthComponent**.

![](/files/ytKXJlKWaxA9codqXLJH)

Double-clicking it will show you the empty [Event Graph](https://docs.unrealengine.com/en-US/ProgrammingAndScripting/Blueprints/UserGuide/EventGraph/index.html).

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

### Listening to Event Landed

Since the Character Blueprint already comes with a [Event Dispatcher](https://docs.unrealengine.com/en-US/ProgrammingAndScripting/Blueprints/UserGuide/EventDispatcher/index.html) for `OnPlayerLanded` we can just subscribe to that!

To do so, get the `Character Core Component` and from there the `Character`. Drag the `Character` reference, create a `Bind Event to On Player Landed` node and createa a new custom Event to it.

Then create a new function named `HandleOnPlayerLanded`. Inside this function we will place the code that is executed when the event fires.

Connect it to the `EventOnPlayerLanded` node.

### Testing the Event Handler

Now our component is ready for testing! To test if our Event Handler is actually called, add a `Print String` node inside of `Handle on Player Landed`.

![](/files/BYQj60jdQj0N4e7Rsc6y)

### Adding Component to Character

For our new component to run we simply need to add it to our Character Blueprint. Open `BP_MotionCharacter`, press `Add Component` in the Components tab, search for the new Health Component and select it.

That's it already! Now to test if the previously added `Print String` node is actually called, hit the Play button in your editor's toolbar and jump. When landing, a message should appear on your screen.

### Adding simple damage logic

This example will only cover a simple example solution for damage. Feel free to adjust and extended the logic as needed for your project.

Add a variable of Type `Float` and name it `Health`. Set it's default value to 100 in the `Details` tab and then replace the code inside of `Handle on Player Landed` with the following code:

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

Create a new variable of Type `Boolean` called `bShowDebugInformation`. Set it\`s default value to `True` and create a new function `Print Debug Information` and add the following code:

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

Then call it in `Event Tick` as follows:

<figure><img src="/files/4FjcNS8wPxVXq08Mtvcz" alt=""><figcaption></figcaption></figure>

Hit the Play button in your editor's toolbar again and it should look like this now when you jump and land:

You have successfully created a component for Motion! Congratulations!


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://motion.docs.regensturm.com/tutorials/creating-a-component.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
