Enable fade and loop motion (CubismMotionController)

[Last updated: 02/07/2020]

Summary

When looping a motion in Cubism Viewer for OW, if “Fade in on 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, if the motion is played in a loop by passing true to the isLoop argument of CubismMotionController.PlayAnimation() in the Cubism SDK for Unity, no fade will occur when returning from the end to the beginning.

By using a callback that is called when motion playback ends, which exists in the CubismMotionController, the same motion can be played anew from the callback to generate a fade and loop the motion.

To set up the above, follow the steps below as an example.

  • Attach CubisMotionController to the model
  • Create a script to perform loop playback processing

The following explanation assumes that you have [imported the SDK] into your project.

 

Attach CubisMotionController to the model

Attach CubismMotionController 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.
If a component that plays motion using CubismMotionController is attached, be careful of interference with the following settings.

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

 

 

Create a script to perform loop playback processing

Create a C# script in the Project window.

Here the name is “CubismMotionLoopPlayer”.

 

Attach the created script to the same level as CubismMotionController in Prefab.

 

Open the created script in a text editor and rewrite the description as follows.

 

With the Prefab on the Scene selected, set the AnimationClip to be looped to CubismMotionLoopPlayer.Animation from the Inspector window.

 

If you play the scene with the above settings, the motion will be played back in a loop, but no fade will occur during the loop.

 

CubismMotionController implements a function to register a callback to be called at the end of motion playback.

 

Using this, modify the aforementioned CubismMotionLoopPlayer so that it does not directly loop playback, but instead plays back the same motion anew when the motion playback ends.
CubismMotionController.AnimationEndHandler callback will not be called if isLoop in CubismMotionController.PlayAnimation() is passed true.

 

This completes the setup.

When the scene is played back in this state, the motion will loop while fading.

© 2010 - 2022 Live2D Inc.