How to Make a Game Like Jetpack Joyride in Unity 2D – Part 3
In the final part of this series, you will generate some coins and lasers, construct a scrolling background, all to some fancy beats. By Mark Placzek.
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Contents
How to Make a Game Like Jetpack Joyride in Unity 2D – Part 3
55 mins
- Getting Started
- Adding Lasers
- Creating a Laser
- Turning the Laser On and Off From the Script
- Setting the Laser Script Parameters
- Killing the Mouse
- Adding the Fall and Die Mouse Animations
- Transitioning to Fall and Die Animations
- Using a Trigger to Make the Mouse Die Once
- Adding Coins
- Creating a Coin Prefab
- Using Tags to Distinguish Coins From Lasers
- Updating MouseController Script to Use Tags
- Generating Coins and Lasers
- Creating a Pack of Coins Prefab
- Adding New Parameters to GeneratorScript
- Adding the Method to Add a New Object
- Generating and Removing Objects When Required
- Setting up Script Parameters
- Adding GUI Elements
- Displaying Coin Count
- Raising the Dead
- Adding Sound and Music
- Hitting Laser Sound
- Collecting Coin Sound
- Jetpack and Footsteps Sounds
- Adding Audio Sources
- Switching Between Footsteps and Jetpack Sounds
- Setting Footstep and Jetpack Script Variables
- Adding Music
- Adding a Parallax Background
- Preparing the Background Images
- Creating Another Camera
- Creating Quads
- Setting Quad Textures
- Making Textures Move
- Fixing the Order of the Cameras
- Where to Go From Here?
Fixing the Order of the Cameras
Select ParallaxCamera in the Hierarchy. In the Inspector, find the Camera component and look for a Depth field. Set it to -2.
However, if you run the game right now you won’t see the parallax background through the window.
To fix this, select the Main Camera in the Hierarchy and set its Clear Flags to Depth Only. This way it won't clear out the picture drawn by the parallax camera.
Run the scene. Now you will see the parallax background through the window.
You now have a fully functioning and decorated game. Great job! Thanks for sticking with it through all three parts!.
Where to Go From Here?
That mouse sure did sacrifice himself many times in the making of this tutorial series. Hopefully you enjoyed the end result though and his deaths were not in vain! If you want to compare your end result you can download the final project from the materials at the top or bottom of this tutorial.
Check out this this video if you want to know more about the making of the actual Jetpack Joyride game.
Creating a parallax background is heavily inspired by this video by Mike Geig, who has a lot of really cool videos on Unity.
Please post your questions and comments below. Thank you for following along with this tutorial! :]