Motion(UE)

Updated: 09/05/2024

This page contains statements regarding the alpha version.

Summary

Motion allows you to play back animations from scripts without having to set up a state machine in the Unreal Engine’s Animation blueprint.

The settings file for the motion function is exported in .motion3.json format.

Click here for more information on how to set up motion. Motion requires the CubismFadeController component and the Unreal Engine’s Animation blueprint.
When an AnimatorController is set as the Animator component, the AnimatorController’s animation will be played instead of Motion.

Click here for the corresponding tutorial article.

How to handle the component

Motion in the Cubism SDK for Unreal Engine can be used by adding a CubismMotionComponent to child components of a CubismModel actor.

If the .motion3.json path is set in .model3.json, CubismMotionComponent is automatically added to the CubismModel actor as a child component during importing, so no configuration on the user side is required.

How to play back motion

When the model is imported, .motion3.json is converted to .uasset for Unreal Editor and added to the Jsons array of CubismMotionComponent.
In Unreal Editor, motion can be applied by specifying for Index the index of the motion to be played back, which is registered in Jsons. Motion is not applied if Index is outside the range of the array index.
The order in which motions are registered can be changed arbitrarily in the editor, and users can also add or delete motions arbitrarily, although this is usually unnecessary.

The following functions provided in CubismMotionComponent are used to control the playing back and stopping of motion.

UFUNCTION(BlueprintCallable, Category = "Live2D Cubism")
void PlayMotion(const int32 InIndex, const float OffsetTime=0.0f, const ECubismMotionPriority Priority=ECubismMotionPriority::Normal);

UFUNCTION(BlueprintCallable, Category = "Live2D Cubism")
void StopAllMotions(const bool bForce = false);
  • PlayMotion
    • InIndex
      Specify the index in Jsons of the motion to be played back.
  • StopAllMotions
    • bForce
      If true is specified, motion is forced to stop without the fade being applied.
      If false is specified, motion stops with the fade being applied.

Update order

CubismMotionComponent is responsible for the motion update process, but the updates are applied after CubismParameterStoreComponent is updated.
This is to ensure that updates made by CubismMotionComponent do not affect the next frame.
Calling CubismParameterStoreComponent::LoadParameters() after updating CubismMotionComponent may result in unintended behavior.

Was this article helpful?
YesNo
Please let us know what you think about this article.