Hi guys,
I’ve got a strange problem with Time.deltaTime. I am moving my character between two points, and I need the walkcycle to animate smoothly between the two, and be ready to repeat at frame 1 when the user holds down the button to move continuously.
What I’ve got at the moment is:
pix.animation.CrossFade("Walkcycle");
for (var t = 0.0; t < 1.0; t += (Time.deltaTime / pix.animation["Walkcycle"].length - .01)) {
pix.transform.position = Vector3.Lerp(startSpot.transform.position, endSpot.transform.position, t);
yield;
}
This works perfectly on iPhone, web, and pc (on a slower computer), but on the PC build and in the editor on a new macbook pro and my gaming pc, things go crazy. The lerp between the positions takes much longer (as if the walkcycle.length has somehow stretched?), so the character moves super slowly between the two points.
I have tried both Update and FixedUpdate. With Update, on a faster PC, the character moves uncontrollably fast. With FixedUpdate, it’s too slow.
If I set the time multiplier to a static value (in this case, 0.78), which fixes it on a faster PC, it seems to create another problem on slower systems: the animation sometimes takes a couple of frames longer than the position lerp (especially if the cpu is chugging), so when the user holds down the button to move continuously between points, it finishes the last frames of the original walkcycle, then just slides the rest of the way.
I have tried CrossFadeQueued, but then it tends to play the walkcycle one time to many when I reach the endspot.
Does anyone have a suggestion? I need framerate independence across all systems, even the fast ones.
Thanks for your help!