0
\$\begingroup\$

I have 2 problems with unity3d.

First, I created an animator and attached it to player. In animator I put 2 condition, Speed and Running (first is float, second is boolean). Default Animation is Idle. Then player press W, I want animation to fade from idle to walk and when he stop press the button, I want the animation to fade from walk to idle. Here is my problem.

  1. When I press W, he make walk animation, but after it he play half of idle animation and after it he enter again in walk animation. How can I loop the walk animation until he release W? And if he release, even if the animation isn't totally played, I need the animator to make transition to idle.
  2. How can I make this "transition"? Then I release W, he just go from walk to idle animation without any transition (and it is a kind of wear).

Second, How can I put 2 input buttons on axes? I mean: If he press W, there should go vertical axes. When he press W+Left Shift, there should go running axes. How can I attach 2 buttons to 1 axes?

I am new in unity and I want to figure out how to work with this things.

\$\endgroup\$
  • \$\begingroup\$ This is two questions. Please try to separate them. \$\endgroup\$ – Fund Monica's Lawsuit Jan 12 '15 at 18:20
1
\$\begingroup\$

Just set your walk animation in the Unity inspector to loop, and use animation.CrossFade for the transition.

if (...) {
  animation.CrossFade (Run.name);                               
} else {
  animation.CrossFade (Idle.name);
}

You can use this for idle animations as well:

if (!animation.isPlaying)
  animation.Play(Idle.name);
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.