Member-only story
2D Player Attack Animations in Unity

To create the 2D attack animations start you go through the same steps that I should in my previous articles to create the animations in the animation window.

The attack will work by creating a trigger parameter for the attack animation. When triggered it will play the animation and go between idle or run depending on the speed of the player.

In your player animations create a method for your attack.
In your Player script create a method to allow the player to attack and call it in the update method.

This will get the player swinging their sword.

Now let’s add the sword swing effect.
Drag the first frame of the sword swing effect into your scene as a child of the player.
Create a new animation for your sword swing effect and record the sword swing effect animation.

In your new animator create an empty state and set that as the starting state and transition to the sword swing effect. This will also be done using a trigger parameter.

The transition back should have an exit time.