I have 2 objects, one with a procedurally animated texture with a repeating cycle of 10 seconds. I’m using Time.time to control the timing.
The other object has two 10 second animations, each created with animation curves. The main animation repeats over and over until the second one is triggered, at which point it needs to wait for the first animation to finish, then play the second. When the 2’nd is finished, the 1’st starts playing(and repeating) again. Everything is on 10 second intervals.
My problem is that the animations of object 2 slowly get out of sync with the object 1.
I’ve tried every combination of animation.Play, PlayQueued, with different wrap modes, but the animations keep getting out of sync.
I was hoping the following code would fix the issue but the animations still get out of sync and slowly get worse. For example, the animations starting to play at 10.02, 20.03, 30.05, 40.1 etc…
IEnumerator Start() {
while(true) {
yield return new WaitForSeconds(10);
if(triggered) {
animation.Play("animation2");
triggered = false;
}
else {
animation.Play("animation1");
}
}
}
Triggering the second animation makes it worse. After a few cycles it starts to get noticeable.
Any ideas what I’m doing wrong?
Thanks