当前位置:网站首页>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 ).
边栏推荐
- Golan no tests were run: fmt Printf() &lt; BUG&gt;
- Unity project hosting platform plasticscm (learn to use 1)
- 力扣704. 二分查找
- 003-JS-DOM-Attr-innerText
- Modbus protocol register
- JS 数组的排序 sort方法详解
- Unit screenshot saved on the phone
- Passing values between classes using delegates and events
- Unity enables simple music visualization
- Error about the new version of UE4: unavigationsystemv1:: simplemovetoactor has been deprecated
猜你喜欢

Create a simple battle game with photon pun

Records of problems encountered in unity + hololens development

Using the command line to convert JSON to dart file in fluent

Meet in Bangkok for a romantic trip on Valentine's Day

Ugui uses its own function to realize reverse mask

力扣2049:统计最高分的节点数目

Unity3d Google Earth

SCM learning notes: interrupt learning

Generate a slice of mesh Foundation

中文版PyCharm改为英文版PyCharm
随机推荐
力扣292周赛题解
Exploration of unity webgl
LXC 和 LXD 容器总结
Unity download and installation website
力扣2049:统计最高分的节点数目
GoLand No Tests Were Run : 不能使用 fmt.Printf() &lt;BUG&gt;
QT connecting external libraries
redis集群概念
Unrealeengine4 - about uobject's giant pit that is automatically GC garbage collected
HTC vive cosmos development - handle button event
Initial environment configuration of the list of OpenGL super classic (version 7) vs2019
2021-07-29 compilation of Cura in ubantu18.04
Malignant bug: 1252 of unit MySQL export
UE4 method of embedding web pages
Procedural animation -- inverse kinematics of tentacles
Oracle-数据的基本操作
Easyrecovery data recovery software recovers my photo and video data two years ago
力扣(LeetCode)180. 连续出现的数字(2022.06.29)
What is multimodal interaction?
Force buckle 704 Binary search