![2d animation unity 2d animation unity](https://i.stack.imgur.com/nFxI0.gif)
#2D ANIMATION UNITY WINDOWS#
Now create the animations for the body, open the animation windows –> create new clip and select the body gameobject sprite rendere component:ĭo the same thing for all the animations that needs to be played on the upper part of the character: Once done, an animation controller along with an animation clip will have been created: Select the legs and drag the frames into the player gameobject to automatically create an animation clip: Now let’s add the animations to our character: Has you can see, our hero has one child gameObject named Body where we’ll use to attach the animations of the body, remember to attach a sprite rendere to the body if your animation is sprite based:Īs you can see, we have 3 animation, one for the legs and 2 for the body.
![2d animation unity 2d animation unity](https://media.giphy.com/media/Y3S9FdlkHIynsJgPaj/giphy.gif)
Let’s create a Hero character with a rigidbody attached:
#2D ANIMATION UNITY HOW TO#
Let see how to use Unity to achieve the result that we want:įirst thing to do Is to create the Avatar to use. Once we have the animations, when the player press the button to attack while the character is running, only the the torso animation will be switched, and to make the transition even more smooth, we’ll use the Animation.Blend method to change from the run animation of the torso to the run-attack animation of the torso.
![2d animation unity 2d animation unity](https://unity.com/sites/default/files/styles/cards_16_9/public/2019-12/Evolutionof2DTools-2DAnimation_0.jpg)
The easy one is to use the Animation.Blend method provided by unity: The problem can be solved with 2 solutions: Now the simple solution is to play the run animation when when player start to run, and switch to the run-attack animation when the player press the attack button, the problem is that the transition between the run and the run-attack animation is not a smooth transition. Let’s assume this situations: You have a 2d character that has a run animation and a run-attack animation, and you want to make the character be able to run and attack at the same time. Let’s see how Unity can help us to solve this problem. How to run two animations at once? This is one of the most common problem in the animations field.