当前位置:网站首页>Unity animator does not clip animation to play animation in segments
Unity animator does not clip animation to play animation in segments
2022-06-30 05:07:00 【zjh_ three hundred and sixty-eight】
public Animator anim;
private AnimatorStateInfo animInfo;
/// <summary>
/// Control animation pause and playback
/// </summary>
int playSpeed = 0;
void Update()
{
animInfo = anim.GetCurrentAnimatorStateInfo(0);
// Judge whether it is playing Take 001 Animation
if (animInfo.normalizedTime < 0.99f && animInfo.IsName("Take 001"))
{
// The first animation
if (animInfo.normalizedTime > 0.19 && animInfo.normalizedTime < 0.2)
{
// Pause animation when conditions are met
print(" Pause play 1");
anim.speed = playSpeed;
}
// The second animation
else if (animInfo.normalizedTime > 0.39 && animInfo.normalizedTime < 0.4)
{
print(" Pause play 2");
anim.speed = playSpeed;
}
else
{
// Automatically set back the stop playing condition
playSpeed = 0;
}
}
}
/// <summary>
/// Start animation
/// </summary>
private void PlayAnim()
{
// Set the conditions for playing the animation
playSpeed = 1;
}animInfo.normalizedTime Animation State Standardization time , An animation value is from 0~1. To 1 Then the animation is played
animInfo.IsName("Take 001") Currently playing animation ,Take 001 Is the name of the animation
principle : First of all, you should know the end frame of each animation , Then the end frame of the animation is divided by the total frame to get the end frame at animInfo.normalizedTime Value , Finally, pause the animation as a condition , Continue to play the animation to realize the start and stop of the next animation .
such as : There is an animation 100 frame , No editing , Need to play multi segment animation .
It is known that the end frame of the first paragraph is 20 frame , that 20/100=0.2,0.2 Then for normalizedTime Value as animation pause condition ( You can set a range when writing conditions ).
边栏推荐
- Moore Manor diary I: realize the reclamation, sowing, watering and harvest in Moore Manor
- Force buckle 349 Intersection of two arrays
- 2021-03-16
- Unity enables simple music visualization
- Writing unityshader with sublimetext
- Nestjs中控制器和路由的配置使用
- Harbor API 2.0 query
- Untiy3d controls scene screenshots through external JSON files
- 【VCS+Verdi联合仿真】~ 以计数器为例
- JPA composite primary key usage
猜你喜欢

Writing unityshader with sublimetext

Ugui uses its own function to realize reverse mask

力扣704. 二分查找

Unity + hololens2 performance test

Force buckle 349 Intersection of two arrays

东塔攻防世界—xss绕过安全狗

Harbor API 2.0 query

UE4 method of embedding web pages

中文版PyCharm改为英文版PyCharm

Deep learning ----- different methods to realize inception-10
随机推荐
Unity realizes rotation and Revolution
Solution to the 292 week match of Li Kou
Unity download and installation website
UnityEngine. JsonUtility. The pit of fromjason()
Unrealeengine4 - about uobject's giant pit that is automatically GC garbage collected
Force buckle 704 Binary search
力扣周赛293题解
Chapter 10 of OpenGL super classic (7th Edition) calculation shader
003-JS-DOM-Attr-innerText
Unity project hosting platform plasticscm (learn to use 2)
Force buckle 209 Minimum length subarray
Detailed explanation of the process of "flyingbird" small game (camera adjustment and following part)
Unity supports the platform # define instruction of script
LxC and LXD container summary
HTC vive cosmos development - handle button event
Database base (Study & review for self use)
svg和canvas的区别
Unity enables simple music visualization
2021-07-29 compilation of Cura in ubantu18.04
力扣59. 螺旋矩阵 II