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

使用说明
例如我们想为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); } } }}
边栏推荐
- When facing complex problems, systematic thinking helps you understand the essence of the problem
- 接口测试工具 restlet client
- The international summit osdi included Taobao system papers for the first time, and end cloud collaborative intelligence was recommended by the keynote speech of the conference
- NPM module removal_ [solved] after NPM uninstalls the module, the module is not removed from package.json [easy to understand]
- 基于腾讯地图实现精准定位,实现微信小程序考勤打卡功能
- 人脸与关键点检测:YOLO5Face实战
- Vivo official website app full model UI adaptation scheme
- The role of the resize function is "suggestions collection"
- GDB locates the main address of the program after strip
- Research on the scheme of MySQL advanced (VIII) sorting problem
猜你喜欢

Huawei occupies half of the folding mobile phone market, proving its irreplaceable position in the high-end market

My heart's broken! After being cheated by 30000, a 16-year-old girl was unconvinced and cheated by 50000

Canvas 填充渐变

Byte side: can TCP and UDP use the same port?

strcpy()

When facing complex problems, systematic thinking helps you understand the essence of the problem

Sum of two numbers and three numbers

Research: more than 70% of doctors are still prescribing unsafe antibiotic drugs

NVIDIA has opened source a comprehensive library of 3D deep learning based on pytorch

Pycharm跑程序时自动进入测试模式
随机推荐
JMeter distributed pressure measurement
[fiddlertx plug-in] use Fiddler to capture the package Tencent classroom video download (unable to capture the package solution)
ag 搜索工具参数详解
My heart's broken! After being cheated by 30000, a 16-year-old girl was unconvinced and cheated by 50000
The international summit osdi included Taobao system papers for the first time, and end cloud collaborative intelligence was recommended by the keynote speech of the conference
Based on pexels image material API, sort out the material resource library
How to copy all files in one folder to another folder
Job interviews are always a second kill? After reading the seckill system notes secretly stored by JD T8, I have given my knees
When facing complex problems, systematic thinking helps you understand the essence of the problem
How to choose sentinel vs. hystrix current limiting?
图片怎么存储到数据库里「建议收藏」
Sqlx library usage
Temperature and humidity environment monitoring system based on stm32
strcpy()
Reading the pointpillar code of openpcdet -- Part 3: Calculation of loss function
Achieve accurate positioning based on Tencent map, and realize the attendance punch function of wechat applet
Apache Shenyu admin authentication bypass vulnerability (cve-2021-37580) analysis and protection measures
Niuke-top101-bm38
Cesium 多边形渐变色纹理(Canvas)
基于腾讯地图实现精准定位,实现微信小程序考勤打卡功能