当前位置:网站首页>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); } } }}
边栏推荐
- Database SQL statement exercise "suggestions collection"
- Record the transfer of domain names from Alibaba cloud service providers to Huawei cloud
- 476-82(322、64、2、46、62、114)
- mysql导入数据时已改成csv utf8文件且文件名为英文,为什么还是导入失败
- Based on pexels image material API, sort out the material resource library
- cv图像翻转,EmguCV图像旋转「建议收藏」
- Fusing and degrading Sentinel
- 2022-07-18: what is the output of the following go language code? A:Groutine; B:Main; C:Goroutine; D:GoroutineMain。 package m
- Beisen Holdings' IPO: a total loss of 4.115 billion yuan in three years, and a total of 2.84 billion yuan in the previous nine rounds of financing
- Fastjson deserialization vulnerability utilization analysis collection
猜你喜欢

两数,三数之和

Focus on data | Haitai Fangyuan directly hits the construction idea of data security governance in the securities industry

浅谈web性能优化(一)

As a test, how to understand thread synchronization and asynchrony

字节一面:TCP 和 UDP 可以使用同一个端口吗?

CNN structural design skills: taking into account speed accuracy and engineering implementation

测试用例和缺陷报告模板

Qixin Jushi cloud spectrum new chapter | Haitai Fangyuan and Sichuan Unicom reach ecological strategic cooperation
![[ManageEngine] value brought by Siem to enterprises](/img/1e/56d64d193e0428523418bef5e98866.png)
[ManageEngine] value brought by Siem to enterprises

2022 latest examination questions and answers of eight members (standard staff) of Shanghai Architecture
随机推荐
In depth understanding of seven specific ways to enhance code scalability
sqlx库使用
Basic method of black box (function) test
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
Interviewer of large factory: how to quickly query a table with tens of millions of data?
Pychart automatically enters the test mode when running the program
ES6---4个强大运算符(??、??=、?.、?:)
C#常见的集合
Oracle RAC RMAN backup error ora-19501 ora-15081
腾讯云数据库的可信可控之路
[FAQ] access the HMS core push service, and the server sends messages. Cause analysis and solutions of common error codes
In June 2021, the interview suffered a Waterloo. Is it so convoluted now
[online tutorial] iptables official tutorial -- learning notes 2
GDB locates the main address of the program after strip
An interview question about concurrent reading and writing of map in golang
Reading the pointpillar code of openpcdet -- Part 3: Calculation of loss function
An interview question about recover in golang
Qixin Jushi cloud spectrum new chapter | Haitai Fangyuan and Sichuan Unicom reach ecological strategic cooperation
Beisen Holdings' IPO: a total loss of 4.115 billion yuan in three years, and a total of 2.84 billion yuan in the previous nine rounds of financing
一道golang中defer和函数结合的面试题