Hi, I'm trying to queue different idle animations, to do this I use AddAnimation function. But I only want to change the animation time to time. The problem is that if I set time2Random for example to 3 sec, the animation interrupts before it ends, but if time2Random is 0, it works fine. I don't want this because the queue may exponentially grow. What I am doing wrong?
void Update () {
SetIdle();
}
void SetIdle () {
timePassed += Time.deltaTime;
if (timePassed >= time2Random) {
SetAnimation("idle" + Random.Range(1, 3), true);
timePassed = 0f;
}
}
void SetAnimation (string name, bool loop) {
if (name == currentAnimation)
return;
skeletonAnimation.state.AddAnimation(0, name, loop, 0f);
currentAnimation = name;
}
18 Mar 2016, 14:21
Maybe I should say I am doing this (even without it the problem remains):
void Start () {
skeleton = skeletonAnimation.skeleton;
skeletonAnimation.state.Start += delegate { skeleton.SetToSetupPose(); };
}