Animating Sprites in Unity
When building 2D games in Unity, animation plays a key role in making characters and objects feel dynamic and engaging. From walking cycles…
Animating Sprites in Unity
When building 2D games in Unity, animation plays a key role in making characters and objects feel dynamic and engaging. From walking cycles to attack moves, sprite animations are the backbone of most 2D visuals. Unity makes this process flexible, offering multiple ways to create and control sprite animations.
What Are Sprite Animations?
A sprite animation is simply a sequence of 2D images (sprites) displayed one after another to simulate motion — much like a traditional flipbook. Unity uses Animation Clips to hold these sequences and play them back on screen.
Method 1: Using a Sprite Sheet
One of the most common approaches is to use a Sprite Sheet — a single texture that contains multiple frames of an animation, usually arranged in a grid.
- First, you slice the sprite sheet into individual frames using Unity’s Sprite Editor.
- Then, you select those frames and drag them into the scene or Animation window.
- Unity automatically compiles them into an Animation Clip that cycles through the frames in order, creating smooth motion.
This approach is efficient, since all animation frames are packed into a single texture.
Method 2: Keyframe Animation in Unity
Another way to animate sprites in Unity is through keyframe animation in the Animation window.
Instead of relying on a sprite sheet, you manually assign sprites or properties (such as position, rotation, or scale) to specific keyframes on a timeline. Unity interpolates the motion or swaps between sprites at the right moments, producing your animation.
This method gives you more control, especially if you want to mix sprite swapping with other animated transformations.
Step-by-Step: Creating a Sprite Animation in Unity
Let’s walk through a simple example of setting up a sprite animation in Unity.
- Select the GameObject. In the Hierarchy, choose the GameObject you want to animate.
- Create a New Animation. Open the Animation window (Window > Animation > Animation). With your GameObject still selected, click Create Animation. Unity will automatically generate both an Animation Clip and an Animation Controller for that object.
- Open the Animation Clip. Once created, open the clip in the Animation window. You’ll see the Dope Sheet, where keyframes are going to be placed on the timeline.
- Enable Record Mode. Click the red Record button to start editing the animation.
- Add Sprite Frames. From your Project window, find the sliced frames of your sprite sheet. Drag and drop them onto the timeline in the Dope Sheet. Adjust the spacing of frames on the timeline to control the playback speed. The closer the frames, the faster the animation.
- Turn Off Record Mode. Once the frames are arranged as desired, click the Record button again to stop recording.
- Test the Animation. Enter Play Mode in Unity. Your GameObject should now play the new animation automatically.
In this workflow, Unity handles much of the setup for you. By simply selecting a GameObject, creating an animation, and dragging in your sprite frames, you can quickly produce fluid 2D animations that respond in-game.
[embed]Sprite Animation: Result
메타데이터
- post_id
- f9a2686330c2
- slug
- animating-sprites-in-unity-f9a2686330c2
- url
- https://medium.com/@250509/animating-sprites-in-unity-f9a2686330c2
- canonical_url
- https://medium.com/@250509/animating-sprites-in-unity-f9a2686330c2
- author_url
- https://medium.com/@250509
- status
- ok
- fetched_at
- 2026-08-15 10:21:01