Enable Fade and Loop Motion (Animator)

Updated: 02/07/2020

Summary

When looping a motion in Cubism Viewer for OW, if “Fade-in during loop playback” is checked, Cubism motion fade and parameter fade will occur when the motion returns from the end to the beginning.
Reference: “Motion Settings

However, when using Unity’s Animator to loop motion within a single state machine, MotionFade does not cause a fade from the end to the beginning.

When looping an AnimationClip, you can generate a fade during looping by assembling two state machines that go back and forth.

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

  1. Attach CubismFadeController to the model
  2. Uncheck Loop Time in AnimationClip
  3. Build AnimatorController

1. Attach CubismFadeController to the Model

Attach CubismFadeController to the GameObject that will be the root of Cubism’s Prefab placed in the Scene.
If it is already attached, there is no need to attach a new one.

In CubismFadeController.CubismFadeMotion, set the .fadeMotionList in which the ID of the AnimationClip to be played in a loop is registered.

2. Uncheck Loop Time in AnimationClip

Select the AnimationClip to be looped and uncheck “Loop Time” from the Inspector window.

3. Build AnimatorController

Create an AnimatorController and set it to the Animator component of the model.

Open AnimatorController in the Animator window, click on the empty space in the graph and attach CubismFadeStateObserver from the Inspector window.

Next, create two state machines on the same layer.
Both state machines created are set to AnimationClip with “Loop Time” unchecked at Step 2.

Finally, right-click on the state machine and click “Make Transition” to connect both of them with a Transition.
Here, Transition is set with Exit Time set to 1 and Transition Duration set to 0.

This completes the setup.

When the scene is played back in this state, the motion will fade while looping.

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