Make Your First Unity 2D Game Easily, with Javascript!

Beginners: Discover the secrets to creating your own simple Unity 2D games with easy-to-use Javascript.
4.7 (177 ratings)
Instead of using a simple lifetime average, Udemy calculates a
course's star rating by considering a number of different factors
such as the number of ratings, the age of ratings, and the
likelihood of fraudulent ratings.
1,020 students enrolled
25% off
Take This Course
  • Lectures 56
  • Length 4.5 hours
  • Skill Level Beginner Level
  • Languages English, captions
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion
Wishlisted Wishlist

How taking a course works


Find online courses made by experts from around the world.


Take your courses with you and learn anywhere, anytime.


Learn and practice real-world skills and achieve your goals.

About This Course

Published 3/2015 English Closed captions available

Course Description

"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.

While this course is aimed at complete beginners to Unity, I do assume you've played around with some kind of programming at some point. But even if you've only played around with HTML and some Javascript you'll do fine.

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!

You'll discover:

  • The basics of using the Unity IDE
  • How to handle physics-based objects
  • Mouse and keyboard interaction
  • Simple animations
  • Audio sound effects and music
  • Using the particle system.
  • Working with Javascript and Unity, plus more.

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!

What are the requirements?

  • At least a beginner-level experience with some kind of programming.
  • A computer capable of downloading and running Unity.
  • Time to go through the course and then play around with the game you created!

What am I going to get from this course?

  • Understand the basics of 2D game development in Unity.
  • Discover the API calls you need for making games.
  • Create your own 2D games.

Who is the target audience?

  • Programmers who want to switch to Unity.
  • Beginning game developers using Unity to make 2D games.

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.


Section 1: Introduction
What You'll Discover
Installing the Unity Game Dev Tool
Section 2: Unity 2D Physics with NO Coding!
The Original (Short!) Video

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.

Right after I finished that last video I reloaded the saved scene and noticed something WEIRD! I still had my recorder going so watch this short video below in case it happens to you!
While you can set the Z-order to a negative number to bring hidden graphics back into view, there's a better way to handle that -- use the power of Sorting Layers with your assets.
5 questions

See how well you remember what you learned in this section.

Section 3: Some Easy Scripting for Unity

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.


Don't worry about which language you're drawn toward, Javascript or C# -- Unity can handle them both. And here's a quick video explaining why either is just fine.


Dip your toes into the world of scripting for Unity. Scripting is:

Using a language like Javascript plus the Unity API to control the game objects in a scene.

Your First Script: Picking Up A Coin (Part 2 of 2)
Simple Scripting
5 questions
Section 4: Diving Deeper Into Scripting

There are many ways to reference a game object in a script, but one of the easiest is available if we “tag” the object. We'll discover how to do that in this video as well as play around with the “if” keyword in Javascript.

The Next Set of Lessons

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.

More Scripting
5 questions
Section 5: Sprite Animation

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.

Animation Using A Sprite Sheet (Part 2 of 2)

Using what we've learned so far, let's take a look at what kind of game we can create.

Animation Quiz
5 questions
Section 6: Audio and Visual Effects

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):


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.

Small Code Change! (Read This!)
Particles and Audio Quiz
5 questions
Section 7: User Interface

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.

User Interface Quiz
5 questions
Section 8: WheelJoint2D

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:

  • Making the camera follow a game object
  • Using a timer to count up seconds on the screen

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.

Section 9: Your Final Project

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.

Students Who Viewed This Course Also Viewed

  • Loading
  • Loading
  • Loading

Instructor Biography

J. A. Whye, Course Instructor

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.

Ready to start learning?
Take This Course