"One Of The Best - J. A. Whye is one of the best teachers. His teaching method is noob proof!"
Everybody knows Unity has been the "go to" tool for making 3D games, but in recent versions they have cranked up the 2D goodness!
In this course for beginners you'll be introduced to the basics of making your own 2D games in Unity. Putting sprites on the screen, making them move, handling input by touch or mouse, and adding sound fx to your game.
The tutorial videos walk you through every single step, so even if you're a newbie, there's nothing to worry about.
We're focusing on 2D game development in this course - starting with NO CODING REQUIRED and going on from there!
"...first time using Unity and I understood everything."
This course was designed to take place over a university semester, but here on Udemy you're able to complete it at your own pace. You can get the basics under your belt and at the end of this course you'll be able to put together simple 2D games using Unity.
Yes, even completely from scratch!
The art and sound assets we'll be using in this course are available free and the course works with the free version of Unity, so you don't need to buy anything else.
Just sharpen your brain and head into the first lesson of the course!
To recreate the scene in the original video (and then go far beyond that), we need a set of graphics for our games. Follow this video to see how to download and import them into our project.
While Unity can be overwhelming, in this video you'll see how easy it is to get sprites (graphics) on the screen and then make them react to gravity.
We'll add a “bouncy” material to the beachball and discover how to create prefabs, or prefabricated game objects.
Finally, we'll create an icy material and play around with what we have, then see how to save the scene so we can come back and work on it later.
See how well you remember what you learned in this section.
Writing some code is going to be necessary to create a complete game using Unity, so let's take a look at what's required.
Dip your toes into the world of scripting for Unity. Scripting is:
For the next set of videos we need a specific scene (because we're building an actual mini-game!), so we'll create that in this video.
If you're an old-hat at scene building and don't need to walk through the process again, just skip to the last of the video to see what it should look like. But I included the video because if you're a Unity newbie this stuff is still not second-nature at this point.
But don't worry, because it will become much easier for you as you keep practicing!
Here we'll create a simple script that will be added to our bomb prefabs.
We've been missing a way for the player to interact with the scene, so let's fix that now.
We'll build a new script that shows how to fire off some code when you click on a game object with your mouse in the scene. Again, our old friend Destroy() pays a visit.
Instantiation is one of those words that strike fear into the heart of evil-doers everywhere. Evil-doers and new game developers. But you can think of it as simply cloning.
Want a new copy of a prefab in your code during the game? Clone it with Instantiate(). Want horrific monsters to drift onto the screen, heading for the heroine who's dropped her sword? Instantiate() those monsters!
Be forewarned — there are a couple concepts that I purposefully gloss over in this lesson, such as Vector3 structures and Quaternions. The good news is that even with the glossiness you'll end up with enough knowledge to be cloning by midnight tonight, guaranteed!*
* Not really guaranteed.
Now that we can instantiate, I want to instantiate all the time, 24/7! So let's discover the secret formula for that…
Static variables give us a way to access variables that are defined in a different script, and functions are one of the core building blocks of coding.
If your game object has a Rigidbody2D component on it, there's a really simple way to get the thing moving — apart from the gravity-based physics that we played with earlier.
This method allows you to “push” the object any direction you want by adding a force to the X (horizontal) or Y (vertical) of the object.
It's easy to dash off a script that works for your current game. But what's smarter is to try and think of ways to write scripts that can be used over and over again in many different games. That's what we'll attempt here.
Most games require the player to move objects or sprites on the screen. Maybe it's a paddle in a Pong-type game, a spaceship exploring the galaxy, or a plumber in a run-and-jump game. So discovering how to handle keyboard-controlled movement is really handy.
It's also pretty easy. While there are some more advanced concepts in the script we'll be writing, the code itself is only 5 lines long! That's my kind of scripting!
So far we've dealt with simple sprites, but there's a cool way to create “internal animation” using sprite sheets. Internal animation refers to animation that happens to/in the sprite itself, such as a bird with flapping wings. The wing animations are a part of the sprite itself — then you'd use AddForce() or something similar to make the flapping bird move across the screen.
This look at sprite sheets is really a “surface” look — there's a lot more to sprite sheets that we won't get into right now.
Let's dive into using sprite sheet animation in Unity.
Using what we've learned so far, let's take a look at what kind of game we can create.
Particle systems (or just, particles) are really cool. They allow you to create animated visual effects without the need for actual artwork (or much artwork, anyway). You can create billowing smoke, explosions, magical sparkles, etc., using particles. They are the kind of things that can really add polish to your game.
Consider the first video below as an introduction to particles -- I'll only touch on what it takes to create a particle from scratch.
For this course I'm going to show you the basics of making a particle, but then switch over and show you how you can use pre-made particles.
Let's create a simple particle effect that will be triggered when we pick up a coin.
Want to save time? Grab some pre-made particle effects.
Whether you've created particles yourself or grabbed some online, now you need to know how to incorporate them into your own code to make your game look cool.
Our scenes have been cool-looking so far — but really, really, quiet. Let's fix that by adding some background music and some sound effects (sfx) when the coins are picked up by the beach ball.
You'll need to download a zip file with three MP3 files in it — we'll be using those in this section. You can find the download link in the resources section to the right (not available on mobile devices).
The sfx are in the public domain and the music we're using is licensed CC3.0 from a guy named Carter – here's a link to the page for the song we're using: Gel (chiptune): http://helloimcarter.com/track/gel-chiptune
Most games have music playing as you're rescuing the hostages, picking up coins, or finding your way through the maze. This video shows how easily you can add background music to your game.
Let's add a sound effect when the player picks up a coin. Those little touches can really add a lot to your game.
So far all our game objects have been visible, but using invisible objects can be really handy at times.
This week is all about the user interface (UI) but it's such a huge subject we're only going to be looking at a couple parts — text elements and buttons.
You'll use text UI for showing the scores, displaying the title of the game, letting the player know when they've won or lost, etc.
In our sample game this week we'll be using only one button, but that button will be doing multiple jobs — making game objects vanish, enabling scripts, and playing music.
The first part of this week's lessons don't need anything special, just create a new scene in any project. But the second part needs a special Unity project so you'll need to download it over on the right (download not available on mobile devices).
Sound used in this lesson: Title: Canadian Geese Migration, recorded by Mike Koenig.
While I'm not new to game development, I'm fairly new to Unity -- this quick video shows how to fix the "problem" I whined about in the previous video.
If you don't have a True Type font laying around to use in this lesson, check the resources to the right for a link to a site that has free fonts you can download.
Add a button to our game.
Now let's see how easy it is to hook the button up to pieces of our project.
Using what we learned in the last section (four videos) let's put the text and button UI elements to use in a little sample game. If you didn't download the sample project in the last section (or did download it, but messed it up), go grab it now.
This won't be a “complete” game but it comes pretty close. And there's nothing stopping you from taking what you now know and adding to it!
The basics of shooting a missile at the enemies. Use the resources at the right (on non-mobile devices only) to grab the Missile.js code that's described in this video.
Using a button to enable and disable a game object component.
Let's add some simple scoring to the game.
In this series of videos we’re exploring a new part of the physics engine in Unity, the idea of joints that can connect one physics object to another.
There are Spring Joints, Slider Joints, Hinge Joints, etc. The one we’re looking at this week is called the Wheel Joint and it’s just like it sounds — makes it easy to attach a wheel to another physics body. In our demo game we’ll create the start of a monster truck racing game.
Besides the WheelJoint2D, we also look at two other topics that could come in handy in many different games:
If you’d like more information on the topics covered in the videos this week, here are some links that will help:
In one of the scripts we used GameObject.FindGameObjectWithTag() but that has apparently been shortened by Unity. The way in the video still works, but you won’t find it documented. Instead, this is the new shortened version:
Slider UI Element
The only thing cooler than a monster truck coasting down hill is one that can put the pedal to the metal, pop wheelies, and fly over jumps. Let’s add a motor to our physics objects.
Here's a function that can be used in many games -- make the camera follow whatever game object you choose.
We need more friction on the tires so we can pop some wheelies!
Before we create the monster truck mini-game, we’re going to look at one way to make your code more efficient.
Note: There are many times when I don’t use the most efficient coding methods in my lessons — simply because many of those techniques are not really beginner level. As you gain more experience with game development you’ll discover more ways to optimize. At the start, it’s not usually that important.
Let's put some pieces together in order to get ready for our monster truck mini-game.
Building the monster truck mini-game.
The "Cheat Sheet" referenced in the next video is the Final Project API Calls document here in the Resources section.
The PDF document referenced in this video is the one you should have downloaded from the Resources section of the previous lecture.
Where you can find free-to-use art assets for your own games.
Jay has been programming professionally since 1988, starting with game programming and then over the years moving to internet programming with a major Seattle telecommunications firm. Jay started programming for mobile devices in 2010 and currently has several games and apps in the Apple App Store with more on the way.
In addition to writing hundreds of technical articles over the years, Jay has recorded dozens of hours of tutorial videos. He's been a speaker at technical conferences and enjoys teaching how to make games and apps almost as much as making games and apps themselves.
Jay is a Certified Developer with Corona SDK, and is also diving into Unity to make 2D games and tutorials.