Your first playable character does not need a 3D model or a rig. For 2D games, a sprite sheet and a few keyframes are enough to get a character that idles, runs, and attacks. This guide walks you through the basics: what a sprite sheet is, how to slice it, and how to hook it up to your game logic so movement and actions feel right.
By the end you will have a character that responds to input with clear idle, run, and (optionally) attack animations.
What You Need Before You Start
- A sprite sheet (one image with several frames in a grid) or separate images for each pose.
- A game engine (Unity or Godot are used in the examples below; the ideas apply to most 2D engines).
- Basic input already working (e.g. moving a placeholder left/right).
If you do not have art yet, use a free placeholder (e.g. from Kenney or OpenGameArt) so you can focus on the animation pipeline.
What Is a Sprite Sheet?
A sprite sheet is a single image that holds multiple frames of animation in a grid. For example, a 4x2 grid might have 8 frames for a run cycle. The engine slices this image into individual frames and plays them in order at a set frames-per-second (FPS) to create animation.
Why use a sprite sheet? One texture is easier to manage and often more performant than many small images. Slicing is done once in the editor; at runtime you just switch which frame (or animation clip) is playing.
Slicing the Sprite Sheet (Unity)
- Import your sprite sheet into Unity (e.g. drag into
Assets/Sprites). - Select the asset. In the Inspector, set Texture Type to Sprite (2D and UI) and Sprite Mode to Multiple.
- Click Sprite Editor. Use Slice > Grid By Cell Count (or Cell Size) to match your grid (e.g. 4 columns, 2 rows).
- Apply and save. Unity generates a mesh for each cell; each cell becomes one Sprite in the asset.
You can then create an Animation clip: open the Animation window, add a GameObject (e.g. your character), create a new clip, and add keyframes that change the Sprite Renderer > Sprite property to the next frame every 0.05–0.1 seconds. Use the Animator to switch between clips (idle, run, attack) from code.
Slicing the Sprite Sheet (Godot 4)
- Import the image. Select it and in the Import dock set Type to Texture2D (or leave as is).
- Create an AnimatedSprite2D node. In the Inspector, create a new SpriteFrames resource.
- In the SpriteFrames editor, add an animation (e.g.
run), then use Add Frames from Sprite Sheet (or add images manually). Set the grid size so frames line up. - Add more animations (e.g.
idle,attack) and assign the right frames to each. - In code or the Inspector, set Animation and call
play("run")orplay("idle")when movement or state changes.
Connecting Animation to Movement
Your character should play idle when not moving and run (or walk) when moving. Optionally, play attack when the player attacks, then return to idle or run.
Unity: In your movement script, get the Animator component and set a bool or float parameter (e.g. IsMoving, Speed). In the Animator Controller, add transitions: Idle to Run when IsMoving is true, Run to Idle when false. Use SetTrigger for one-shot actions like attack.
Godot: In _physics_process, check velocity.x (or input). If non-zero, call $AnimatedSprite2D.play("run") and set flip_h from velocity; otherwise play("idle"). When attacking, play("attack") and use the animation_finished signal to go back to idle or run.
Pro tip: Keep frame counts low at first (e.g. 4–6 for idle, 6–8 for run). You can add more frames and tweak FPS once the logic feels good.
Flipping and Facing Direction
For a 2D side view, you usually have one set of frames and flip the sprite horizontally so the character faces left or right. In Unity, set the Sprite Renderer > Flip X (or scale.x to -1) from code based on move direction. In Godot, set AnimatedSprite2D > Flip H from code. Update the facing direction when movement or aim direction changes, not every frame randomly.
Common Mistakes
- Wrong slice size: If the grid in the sprite sheet does not match the slice (e.g. 8 frames but you sliced 6), frames will be misaligned or stretched. Double-check the artist’s grid or document the cell size.
- Playing the wrong clip: Ensure you are setting the correct animation name or parameter. A typo (e.g.
"Idle"vs"idle") can leave the character stuck on one clip. - No transition back from attack: If you play attack and never switch back, the character will freeze on the last attack frame. Use animation events, the
animation_finishedsignal (Godot), or Animator states (Unity) to return to idle or run.
Quick Checklist
- Sprite sheet imported and (in Unity) Sprite Mode set to Multiple, then sliced in Sprite Editor.
- In Godot: SpriteFrames created with idle, run, and (optional) attack animations.
- In Unity: Animation clips and Animator Controller with Idle and Run (and optional Attack), with transitions driven by movement or triggers.
- Code updates facing direction (flip) from move or aim input.
- Code plays the right animation (or sets the right parameter) when movement or attack state changes.
Where to Go Next
- Add more states (e.g. jump, hurt, death) and blend or transition between them.
- In Unity, use Animation Events to trigger sounds or spawn effects on a specific frame.
- In Godot, use animation_finished to chain animations or enable input again after an attack.
For deeper guides, see our Game Animation Principles and Creating Game VFX posts. For engine-specific paths, check our Unity and Godot guides. Bookmark this if you are building your first 2D character; share it with your team if it helped.