- Home /
Question by
DungDajHjep · May 21, 2015 at 03:55 PM ·
animationspeedsmooth
Problem : Change speed animation when run it not smooth
I change speed animation by animator.speed in OnUpdate(), but animation move not smooth, anyone can help me ?
void Update()
{
switch (state)
{
case State.IncreaseSpeed:
if (animator.speed < 3f)
animator.speed += Time.deltaTime * 1.2f;//1.2f
break;
case State.WaitResult:
if (spinController.isGetDataCompleted)
state = State.DecreaseSpeed;
break;
case State.DecreaseSpeed:
if (animator.speed > 0)
animator.speed -= Time.deltaTime * 1.4f;//1.4f
if (step >= 3 & animator.GetCurrentAnimatorStateInfo(0).normalizedTime > 4.995f)
{
animator.speed = 0;
state = State.Stop;
}
break;
}
}
You can see my animation here, i can make a video if u want.
Comment
I would check those keyframes at 1:00. I guess there are some problems.
Answer by abhi_360 · May 22, 2015 at 04:51 AM
private const float minSpeed=0;
private const float maxSpeed=3;
public float curSpeed;
if(animator.speed< maxSpeed)
animator.speed=Mathf.Lerp(animator.speed,maxSpeed,Time.deltaTime*curSpeed);
if(animator.speed> minSpeed)
animator.speed=Mathf.Lerp(animator.speed,minSpeed,Time.deltaTime*curSpeed);
just tweak curSpeed in the inspector
hi, thanks for suport but it's not work smooth, think problem is animation , i will change animation by scrollrect infinite, thanks again !
Your answer
![](https://koobas.hobune.stream/wayback/20220613200131im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Animation speed control - no smooth animation on slow down 3 Answers
Animation Stop and Stay 1 Answer
How to get and change animation speed of animator? 2 Answers
Convert BPM to Animation.speed 0 Answers