Play Back Animation

Updated: 01/30/2020

This tutorial describes how to play an embedded animation file exported from the Cubism Editor on a model in a Unity project.

The following explanation is based on the assumption that the project is the same as the project for which the [Import SDK – Place Models] was performed.

Summary

To play Cubism animations in a Unity project, a motion file in .motion3.json format is required.
See “Data for Embedded Use” for information on exporting motion files.

The SDK also provides an Importer for .motion3.json as well as models, and .motion3.json is automatically converted to Unity’s animation format, AnimationClip, upon import.

The converted AnimationClip makes it possible to handle animations in Unity using only Unity’s built-in functions, without using Live2D’s functions.

 

The procedure for playing back motion in a Unity project is as follows.

  • Import motion files
  • Play AnimationClip

Import motion files

Drag and drop a motion file exported from the Cubism Editor for embedding into the Project View, along with the folder containing it.

Then, an AnimationClip is generated from .motion3.json, as shown in the following image.
Loop can also be set for the generated AnimationClip.

Tips

The AnimationClip has a curve with values to set for each parameter of the model, and the properties for the parameters set by this curve are located in the following hierarchy of the model’s Prefab. (Value is hidden in Inspector.)

[model root]/Parameters/[Parameter ID]/Cubism Parameter/Value

The maximum and minimum values to be set for Value are different for each parameter ID, but values outside that range are treated as maximum or minimum values.

The opacity of the part is also located in the following hierarchy of Prefab. (Opacity is hidden in Inspector.)

[model root]/Parameters/[Part ID]/Cubism Part/Opacity

The value set for Opacity ranges from 0 to 1. Values outside this range are treated as 0 or 1.

Specifying these properties will allow you to manipulate the parameters of the model and the opacity of the parts from an AnimationClip or program created in Unity.

Play AnimationClip

There are several ways to play an AnimationClip in Unity, but here we will use Animator as an example.

Drag and drop the AnimationClip generated by “Import Motion Files” onto the root GameObject of the model.

When a Scene is executed in this state, the animation is played.

As mentioned above, Cubism’s animation format is converted to AnimationClip when imported into a project, allowing for management of transitions and blending of multiple motions in Animator.

See “Unity Manual” for details.

Tips

In the Live2D Cubism SDK for Unity, the fade time set in .motion3.json is disabled by default.
See “Enabling Motion Fade in Mecanim” for instructions on enabling fades in .motion3.json.

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