Hi,
I’m kind of new to unity, so forgive me if this is the wrong place to ask this question. I did this test with a 2D character, but it’s not animating quite like I expected it to:
http://dancoes.net/misc/WebTest/Pig.html
What I’m doing is scaling each sprite plane to 100% then back to 0% on each frame (maya/FBX doesn’t export the visibility animation).
Why is it that sometimes when the character stops running, there’s still a frame from the run cycle being shown?
Here’s my animation code.
Thanks in advance for any suggestions.
function Start (){
animation.wrapMode=WrapMode.Loop;
animation["run"].layer=-1;
animation["idle"].layer=-1;
animation.SyncLayer(-1);
animation["jump"].layer=-10;
animation["jump"].wrapMode=WrapMode.Once;
animation.SyncLayer(10);
animation.Stop();
animation.Play("idle");
}
function FixedUpdate (){
if(Input.GetButton("Jump"))
{
animation.Play("jump");
}
if (Input.GetAxis("Horizontal")>.2 || Input.GetAxis("Horizontal")<-.2)
{
animation.Play("run");
}
else
{
walkTime=0;
animation.Play("idle");
}
if (Input.GetKey ("right")) {
transform.localScale.z = 0.176531;
}
if (Input.GetKey ("left")) {
transform.localScale.z = -0.176531;
}
}