Enable fade to loop motion (Animator)
[Last updated: 02/07/2020]
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, 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 is a description of the procedure based on the assumption that the project is the same as the project for which the [Import SDK] was performed.
- Attach CubisFadeController to the model
- Uncheck Loop Time in AnimationClip
- Build AnimatorController
1. Attach CubisFadeController 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.
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 2.
Finally, right-click on the state machine and click “Make Transition” to connect each 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 loop while fading.