当前位置:网站首页>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); } } }}
边栏推荐
- A detailed explanation of SCP command
- CNN structural design skills: taking into account speed accuracy and engineering implementation
- 字节一面:TCP 和 UDP 可以使用同一个端口吗?
- Kali modify the update source (it is not safe to update with this source)
- seven point two three
- The onnx model is exported as a TRT model
- Sum of two numbers and three numbers
- Fusing and degrading Sentinel
- 一道golang中关于接口和实现的面试题
- Byte side: can TCP and UDP use the same port?
猜你喜欢

工作面试总遇秒杀? 看了京东 T8 大咖私藏的秒杀系统笔记, 已献出膝盖

Pychart automatically enters the test mode when running the program

Opencv learning Fourier transform experience and line direction Fourier transform code

黑盒(功能)测试基本方法

JMeter distributed pressure measurement

【网络教程】IPtables官方教程--学习笔记2

Too many passwords, don't know how to record? Why don't you write a password box applet yourself

476-82(322、64、2、46、62、114)

Airtest解决“自动装包”过程中需要输入密码的问题(同适用于随机弹框处理)

How to choose sentinel vs. hystrix current limiting?
随机推荐
How to store pictures in the database "suggested collection"
Vivo official website app full model UI adaptation scheme
Zero basic learning canoe panel (17) -- panel CAPL function
Interviewer of large factory: how to quickly query a table with tens of millions of data?
DDD go practice
一道golang中关于recover的面试题
Using the OAP aspect causes the controller to be called repeatedly
MPI learning notes (II): two implementation methods of matrix multiplication
[fiddlertx plug-in] use Fiddler to capture the package Tencent classroom video download (unable to capture the package solution)
3阶有向完全图的所有非同构的子图(不同钩子图个数)
When MySQL imports data, it has been changed to CSV utf8 file and the file name is English. Why does it still fail to import
C#程序设计的6大原则
ES6 --- four powerful operators (?,? =,?.,?:)
NVIDIA has opened source a comprehensive library of 3D deep learning based on pytorch
Based on pexels image material API, sort out the material resource library
租房二三事
数据库sql语句练习题「建议收藏」
Temperature and humidity environment monitoring system based on stm32
【C语言入门】ZZULIOJ 1016-1020
Vivo official website app full model UI adaptation scheme