当前位置:网站首页>Unity metaverse (II), mixamo & animator hybrid tree and animation fusion
Unity metaverse (II), mixamo & animator hybrid tree and animation fusion
2022-07-26 07:43:00 【CoderZ1010】
List of articles
Mixamo
brief introduction
MixamoyesAdobeThe company launched online freeCharacter animation library, Address :Mixamo, We can search for the character animation needed for development and download it .

Instructions
For example, we want to Avatar Add a role Idle Animation , stay Search Search in the search bar :

Can pass UPLOAD CHARACTER Upload our own Avatar Model to preview the animation effect :

Click on DOWNLOAD You can download the corresponding character animation , After downloading to Unity in , stay Import Settings Import settings Rig Window , take Animation Type That is, the animation type is changed to Humanoid Human animation :

Unity Animator
Blend Tree Mixed tree
Blend TreeyesAnimator ControllerA special state type in animation state machine , Used between multiple animationsSmooth blend, The influence of each animation on the final effect is determined byMixing parameterscontrol , It is often used to deal with the blending between mobile animations .
For example, we are in Mixamo The animation library is downloaded Idle、Walk、Sprint, That is, static 、 walk 、 Run three animations , Next, I want to use Blend Tree Through a parameter Speed That is to control the mixing between the three animations by moving speed .
First of all, these three animated Loop Time Set to true, It means that they are Loop Playback Of :

stay Animator Pass through Right click > Create State > From New Blend Tree To create a hybrid tree , Name it Move, And create parameters Speed:

Double click to enter the hybrid tree , Add three stills 、 walk 、 Run three animations , Because we use a parameter Speed To control mixing , therefore Blend Type Use default 1D The way ,Threshold The thresholds are set to 0、10、25:

Set through the value entered by the user Speed Parameters :
using UnityEngine;
namespace SK.Framework.Avatar
{
/// <summary>
/// Avatar Animation control
/// </summary>
public class AvatarAnimatorController : AvatarMovementController
{
// Animation parameters
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);
}
}
}

Animation fusion
Animation fusion refers to the fusion playback between two animations , For example, in the third person shooting game, players shoot while walking , It can be understood as moving + Fusion playback of shooting animation :

Here we walk + Take the animation fusion of greeting as an example , We are Mixamo Download one from the animation library Wave Animation , stay Animator Create a new Layer Hierarchy , take Weight The weight is set to 1,Blending Set to Override The way , And create a Avatar Mask:

Avatar Mask Disable other parts except the right hand and right arm , Because we only need our right hand and right arm to greet :

Add one Trigger Parameters of type , Used to trigger Wave action :

Suppose the user presses Shortcut key 1 Trigger when Wave action :
using UnityEngine;
namespace SK.Framework.Avatar
{
/// <summary>
/// Avatar Animation control
/// </summary>
public class AvatarAnimatorController : AvatarMovementController
{
// Animation parameters
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);
}
}
}
}

边栏推荐
猜你喜欢

MMOE multi-objective modeling

How to ensure the double write consistency between cache and database?

DevExpress.XtraEditors.DataNavigator用法

Establishment and use of openstack cloud platform

Examples of financial tasks: real-time and offline approval of three scenarios and five optimizations of Apache dolphin scheduler in Xinwang bank

MySQL之执行计划

Program environment and pretreatment

Vscode cannot start the problem solving idea

20220209 create a basic Servlet

什么是消息订阅和发布?
随机推荐
Regular expression rules and common regular expressions
OVS底层实现原理
Common database commands (special for review)
现在开发人员都开始做测试了,是不是以后就没有软件测试人员了?
Comparison and difference between dependence and Association
程序环境和预处理
[200 opencv routines] 231. Gray level co-occurrence matrix (GLCM) for feature description
Distributed system and distributed database system (Introduction)
PyTorch
Fang Wenshan, Jay Chou's best partner, will officially announce "Hualiu yuancosmos" on July 25
Abnormal (2)
Regression analysis code implementation
Hcip--- MPLS detailed explanation and BGP route filtering
Program environment and pretreatment
ARIMA model for time series analysis and prediction
Taishan office lecture: word error about inconsistent values of page margins
C语言关键字extern
Kdd2022 | uncover the mystery of Kwai short video recommendation re ranking, and recommend the new SOTA
tensorflow2.x中的量化感知训练以及tflite的x86端测评
Audio and video learning (10) -- PS streaming