Motion 1.4
AnimateMotionglTF Batch Exporter
  • Getting Started
  • Tutorials
    • Add Footsteps to Motion
    • Add Surfaces to Motion
    • Camera Transitions
    • Creating a component
    • Retargeting Marketplace Characters
    • Using Metahumans
  • Tweaking
    • Breathing Shake
    • Crouch Deceleration
    • Jump Camera Bounce
    • Sneak Deceleration
    • Sneak Shake
    • Sprint Acceleration
    • Sprint Shake
    • Movement Sounds
  • Components
    • BP_BaseCurveManager
    • BP_BaseCharacterCurvedComponent
    • BP_BaseMotionManager
    • BP_BreathingComponent
    • BP_CharacterCoreComponent
    • BP_CharacterCurveManager
    • BP_CoreComponent
    • BP_CrouchingComponent
    • BP_CurvedComponent
    • BP_IdleComponent
    • BP_JumpingComponent
    • BP_MotionCharacter
    • BP_MotionComponent
    • BP_MovementSoundComponent
    • BP_SneakingComponent
    • BP_SprintingComponent
    • BP_TrueFirstPersonComponent
    • BP_WalkingComponent
  • Architecture
    • ECurvePositions
    • ECurveTimes
    • EMovementDirections
    • EMovementEvents
    • EMovementSoundTypes
    • ETransitionCurves
    • ETransitionPositions
    • FStructCameraCurve
    • FStructCameraCurveTransition
    • FStructCharacterGroundInfo
    • FStructMotionCurve
    • FStructMotionCurveConfiguration
    • FStructMotionCurveIdentifier
    • FStructMotionCurveTransition
    • FStructMotionCurveTransitionConfiguration
    • FStructMovementSound
Powered by GitBook
On this page
  • Creating a Motion Component
  • Listening to Event Landed
  • Testing the Event Handler
  • Adding Component to Character
  • Adding simple damage logic
  1. Tutorials

Creating a component

Last updated 2 years ago

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 by right-clicking in the and selecting Blueprint Class.

In the modal that opens, scroll down and select BP_BaseCharacterCurvedComponent.

Name it BP_HealthComponent.

Listening to Event Landed

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.

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:

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:

Then call it in Event Tick as follows:

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!

Double-clicking it will show you the empty .

Since the Character Blueprint already comes with a for OnPlayerLanded we can just subscribe to that!

Event Graph
Event Dispatcher
Actor Component
Content Browser