- Home /
How to play animation when player is moving?
What is the simplest way to add a walking animation. I want my 'walkright' animation to play when my character is moving right, and my 'walkleft' animation to play when the character is moving left. I am new to Unity so don't know anything about animation or animator controllers. Please let me know how to do this...
Answer by Yoshinator2 · Jul 26, 2017 at 01:31 AM
Add an animator to the object and have bools in the animator, one for walking right, and one for walking left. Have the walking script set the bools values depending on the direction that the player is walking. Then, just have the animations play depending on the bools :)
Thanks! Is there any way to make the transition between animations instant, ins$$anonymous$$d of waiting for the animation to finish playing? Because, when my character walks, the animation plays, which is good, but when I release the right arrow key, the animation continues playing for a split second and it looks bad...
Yes, as Persian$$anonymous$$iller said below, just uncheck the Has Exit Time after you click on the arrow that has the animation transition. If my answer solved your problem, please click the "Accept" button on the bottom right of it :)
Answer by PersianKiller · Jul 26, 2017 at 07:50 AM
make sure Has Exit Time is not Checked, if it is 1 sec it means it will be stop playing after 1 sec .