Daily Progression: Attack Animation When Idle

addam davis
3 min readNov 18, 2021

Objective: Create an attack animation when are player is idle.

If you have been following along with my tutorials then we have created an animation for being idle, running, and jumping. At this point you should be getting familiar with this process. In this tutorial we are going to create an animation for our player to attack.

We begin the same way we have been with creating multiple sprites by slicing one sprite into multiple sprites.

Select the sprite object under you player object and on the animation window click the drop down arrow and select create new clip.

Save this attack animation with the other animation.

This automatically adds the animation to the animator window.

Create transitions to and from idle and attack.

We need a new parameter, this time we are going to use a trigger.

On the transition to attack, add a condition and use the trigger we just created. Has exit time should be false, and the transition duration needs to be 0.

The transition will have exit time being true, the transition duration needs to be 0 and add the condition of our move parameter being less that 0.1.

Now we want to go into our animation window and create the attack animation. Drag in the frames you want to use. Just because we created a load of sprites, doesn’t mean we have to use all of them. for instance, my sprite created 35 sprites and I am only using 17 of them.

Set the sample rate to the rate you like, for me that is 25. Then with the scene window visible you can preview your animation.

In the next tutorial we will look at triggering this animation with code and creating proper transition so we can attack while moving as well! Don’t be afraid to experiment with your animations and I’ll see you in the next tutorial!

--

--