pascalkk :I could switch two animation smoothly already. Just like:
void Start()
{
skeletonAnimation= GetComponent<SkeletonAnimation>();
state = skeletonAnimation.AnimationState;
state.SetAnimation(0, "walk", true);
state.SetEmptyAnimation(1, 0);
state.AddAnimation(1, "run", true, 0).mixDuration = 1.5f;
//state.AddEmptyAnimation(1, 10f, 3);
}
or:
void Start()
{
skeletonAnimation = GetComponent<SkeletonAnimation>();
state = skeletonAnimation.AnimationState;
//获取状态机动画数据
stateData = skeletonAnimation.SkeletonDataAsset.GetAnimationStateData();
//设置动画混合,第一个参数是 当前动画,第二参数是下一个动画,第三个参数是从当前动画过度到下一个动画所需时间
stateData.SetMix("walk", "run", mixTime);
stateData.SetMix("run", "walk", mixTime2);
skeletonAnimation.AnimationState.SetAnimation(0, "walk", true);
}
void Update()
{
if (Input.GetKeyDown(KeyCode.A))
{
skeletonAnimation.AnimationState.SetAnimation(0, "run", true);
}
if (Input.GetKeyDown(KeyCode.D))
{
skeletonAnimation.AnimationState.SetAnimation(0, "walk", true);
}
}
But I don't know how to mix two animation by weight ,just like 50%.
There are two Topic talk about this before:
http://zh.esotericsoftware.com/forum/Can-you-mix-with-the-bind-pose-7755?p=36137&hilit=SetMix#p36137
http://zh.esotericsoftware.com/forum/How-to-create-Mixing-Animation-3465
and I couldn't make this correct after read this. so, is there some detail?
just like ue4 animation blend in BlendSpace? like: