Mario Game in Unity 6 (2025) | Part 3: Adding Animations (Idle, Run, Jump)
Animations are what make a game truly come alive. In Part 3 of this series, we’ll add animations to Mario for idle, running, and jumping states using Unity 6. This step will transform our simple character movement into a polished and interactive experience.
By the end of this tutorial, you’ll learn how to set up animations, configure the Animator Controller, and write C# scripts to handle animation transitions based on player input.
What Are We Doing in Part 3?
- Importing already-sliced Mario sprites for animation.
- Creating animations for idle, running, and jumping.
- Setting up an Animator Controller.
- Writing scripts to control animation transitions dynamically.
Step 1: Importing the Sprite Sheet
1.1. Import the Sprite Sheet
Download File- Download the pre-sliced Mario sprite sheet provided in this tutorial.
- Drag the sprite sheet into your Unity project’s Assets folder.
Since the sprite sheet is already sliced, there’s no need to use the Sprite Editor. The sprites will appear as individual assets in the Project panel.
Step 2: Creating Animations
2.1. Create Animation Clips
- In the Project panel, create a new folder named
Animations. - Drag the appropriate sprites for idle, run, and jump into the Scene view to create separate animation clips for each state.
- Name the clips
Idle,Run, andJump.
- Name the clips
2.2. Configure the Animator Controller
- Right-click in the
Animationsfolder and create a new Animator Controller. Name itPlayerAnimator. - Assign the
PlayerAnimatorto the Mario character by selecting the GameObject in the Hierarchy and attaching the Animator Controller in the Inspector. - Open the Animator window and drag the
Idle,Run, andJumpanimations into it.
Step 3: Adding Animation Transitions
3.1. Set Up Animator Parameters
- In the Animator window, create two new parameters:
Running(Bool)Jumping(Bool)
3.2. Configure Transitions
- Create transitions between the Idle, Run, and Jump states based on the parameters:
- Idle → Run: Add a condition where
Runningistrue. - Run → Idle: Add a condition where
Runningisfalse. - Idle/Run → Jump: Add a condition where
Jumpingistrue. - Jump → Idle/Run: Add a condition where
Jumpingisfalse.
- Idle → Run: Add a condition where
Step 4: Writing the C# Script
Step 5: Testing Your Animations
- Play the game and move Mario using your movement controls from Part 2.
- Observe Mario transition smoothly between idle, run, and jump animations as you interact with the game.
What’s Next?
Now that Mario can move and animate beautifully, it’s time to make the game more interactive. In Part 4, we’ll add collectible coins and enemies to enhance gameplay and challenge the player. Stay tuned for the next part!
Watch the Video
Check out the step-by-step video tutorial for Part 3 on YouTube for a detailed walkthrough:
Join the Series
Follow this blog and subscribe to the YouTube channel to stay updated with the next parts of the Mario game development series. Let’s keep building this classic game together!
#Unity6Tutorial #MarioGameDevelopment #2DGameAnimations #UnityAnimator #LearnUnity #GameDevelopment
.jpg)
Comments
Post a Comment