当前位置:网站首页>Unity Metaverse(二)、Mixamo & Animator 混合树与动画融合
Unity Metaverse(二)、Mixamo & Animator 混合树与动画融合
2022-07-26 07:39:00 【CoderZ1010】
Mixamo
简介
Mixamo是Adobe公司推出的在线免费角色动画库,地址:Mixamo,我们可以在上面搜索开发所需的角色动画并下载使用。

使用说明
例如我们想为Avatar角色添加一个Idle动画,在Search搜索栏中进行检索:

可以通过UPLOAD CHARACTER上传我们自己的Avatar模型来预览动画效果:

点击DOWNLOAD便可以下载对应的角色动画,下载完成后导入到Unity中,在Import Settings导入设置Rig窗口中,将Animation Type即动画类型改为Humanoid人形动画:

Unity Animator
Blend Tree 混合树
Blend Tree是Animator Controller动画状态机中的一种特殊状态类型,用于多个动画之间的平滑混合,每个动画对最终效果的影响由混合参数控制,经常用于处理移动动画之间的混合。
例如我们在Mixamo动画库下载了Idle、Walk、Sprint,即静止、行走、奔跑三个动画,接下来想要使用Blend Tree通过一个参数Speed即移动速度来控制这三个动画之间的混合。
首先将这三个动画的Loop Time都设置为true,表示它们都是循环播放的:

在Animator中通过右键 > Create State > From New Blend Tree来创建一个混合树,命名为Move,并创建参数Speed:

双击进入混合树,添加三静止、行走、奔跑三个动画,由于我们使用一个参数Speed来控制混合,所以Blend Type使用默认的1D方式,Threshold阈值分别设置为0、10、25:

通过用户输入的值来设置Speed参数:
using UnityEngine;
namespace SK.Framework.Avatar
{
/// <summary>
/// Avatar动画控制
/// </summary>
public class AvatarAnimatorController : AvatarMovementController
{
//动画参数
private static class AnimatorParameters
{
public readonly static int Speed = Animator.StringToHash("Speed");
}
private Animator animator;
protected override void Start()
{
base.Start();
animator = GetComponent<Animator>();
}
protected override void Update()
{
base.Update();
animator.SetFloat(AnimatorParameters.Speed, Mathf.Clamp01(input.magnitude) * speed);
}
}
}

动画融合
动画融合是指两个动画之间的融合播放,例如第三人称射击游戏中玩家边走边射击的动作,可以理解为移动+射击动画的融合播放:

这里我们以行走+打招呼的动画融合为例,我们在Mixamo动画库中下载一个Wave动画,在Animator中创建一个新的Layer层级,将Weight权重设为1,Blending设为Override方式,并创建一个Avatar Mask:

Avatar Mask禁用掉除了右手和右臂之外的其它部位,因为我们打招呼的动作只需要右手和右臂起作用:

添加一个Trigger类型的参数,用来触发Wave动作:

假设用户按下快捷键1时触发Wave动作:
using UnityEngine;
namespace SK.Framework.Avatar
{
/// <summary>
/// Avatar动画控制
/// </summary>
public class AvatarAnimatorController : AvatarMovementController
{
//动画参数
private static class AnimatorParameters
{
public readonly static int Speed = Animator.StringToHash("Speed");
public readonly static int Wave = Animator.StringToHash("Wave");
}
private Animator animator;
protected override void Start()
{
base.Start();
animator = GetComponent<Animator>();
}
protected override void Update()
{
base.Update();
animator.SetFloat(AnimatorParameters.Speed, Mathf.Clamp01(input.magnitude) * speed);
if (Input.GetKeyDown(KeyCode.Alpha1))
{
animator.SetTrigger(AnimatorParameters.Wave);
}
}
}
}

边栏推荐
- Summarize the common high-frequency interview questions of the software testing post
- HOT100 hash
- Interview question set
- Meta universe infrastructure: analysis of the advantages of Web 3.0 chain33
- Selenium: detailed explanation of browser crawler use (I)
- Speech at 2021 global machine learning conference
- JWT quick start
- Installation of Baidu flying paste deep learning framework tutorial in Anaconda
- TensorFlow学习日记之tflearn
- How to ensure the double write consistency between cache and database?
猜你喜欢

【uniapp】多种支付方式封装

Learning Efficient Convolutional Networks Through Network Slimming

Taishan office lecture: word error about inconsistent values of page margins

Devaxpress.xtraeditors.datanavigator usage

Apache dolphin scheduler 2.x nanny level source code analysis, China Mobile engineers uncover the whole process of service scheduling and start

Practice of online question feedback module (XIV): realize online question answering function

2021全球机器学习大会演讲稿

Speech at 2021 global machine learning conference

C # use log4net to record logs (basic chapter)

DADNN: Multi-Scene CTR Prediction via Domain-Aware Deep Neural Network
随机推荐
Kdd2022 | uncover the mystery of Kwai short video recommendation re ranking, and recommend the new SOTA
1. MySQL Architecture [MySQL advanced]
[classic thesis of recommendation system (10)] Alibaba SDM model
:app:checkDebugAarMetadata 2 issues were found when checking AAR metadata: 2 issues were found when
[C language] do you really know printf? (printf is typically error prone, and collection is strongly recommended)
Fang Wenshan, Jay Chou's best partner, will officially announce "Hualiu yuancosmos" on July 25
1.MySQL架构篇【mysql高级】
2022.7.22DAY612
系统架构&微服务
爬虫->TpImgspider
Now developers are beginning to do testing. Will there be no software testers in the future?
Vscode cannot start the problem solving idea
Selenium: detailed explanation of browser crawler use (I)
WCF introductory tutorial II
WCF deployed on IIS
tensorflow2.x中的量化感知训练以及tflite的x86端测评
Wrong Addition
Summarize the common high-frequency interview questions of the software testing post
[200 opencv routines] 231. Gray level co-occurrence matrix (GLCM) for feature description
QT listview add controls and pictures