Now that the spritesheet with the animation cycle is correctly split up, we can use the multiple sprites to create a walking animation for our character.
In this recipe, we will use the spritesheet we set up in the previous recipe to create an animation cycle for a character sprite.
walk
and save it in the Anims folder inside Assets, which is in Sprites, as shown in the following screenshot:Once a spritesheet is split into several frames, Unity is automatically capable of displaying them within an animation clip in a given order and at a given frame rate. The clip is then attached to the Animation component of a game object so that the game object can perform the animation clip defined in the spritesheet.
Using spritesheets is not the only way to animate sprites. Actually, there are cases where keyframe animation may be preferred.
With keyframe animation, a clip is obtained as a sequence of keyframes on a timeline. In each keyframe, the character is set in a pose that is a step of the final animation we aim to create. Unity takes care of interpolating the movement of each individual animated part of the sprite between one keyframe and the next. Thus, when we play the animation clip on the timeline, the result we get is coherent, progressive animation.
This is the same concept of spritesheet animation after all; the difference is that no predrawn spritesheet is required with skeletal animation and the character can be directly animated. As such, animating sprites with keyframe animation is actually an optimization technique, as it reduces the amount of data required to store several spritesheets in the project. We suggest you visit the following links to go deeper into this matter:
In order to use skeletal animation, the character must be provided with so-called joints. This is the topic of our next recipe.
18.191.237.201