Make Your First Unity 2D Game Easily, with Javascript!
4.0 (210 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,162 students enrolled
Wishlisted Wishlist

Please confirm that you want to add Make Your First Unity 2D Game Easily, with Javascript! to your Wishlist.

Add to Wishlist

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.0 (210 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,162 students enrolled
Created by J. A. Whye
Last updated 11/2015
Current price: $10 Original price: $20 Discount: 50% off
5 hours left at this price!
30-Day Money-Back Guarantee
  • 4.5 hours on-demand video
  • 7 Articles
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
What Will I Learn?
  • Understand the basics of 2D game development in Unity.
  • Discover the API calls you need for making games.
  • Create your own 2D games.
View Curriculum
  • 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!

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

Who is the target audience?
  • Programmers who want to switch to Unity.
  • Beginning game developers using Unity to make 2D games.
Students Who Viewed This Course Also Viewed
Curriculum For This Course
56 Lectures
2 Lectures 02:12

Installing the Unity Game Dev Tool
Unity 2D Physics with NO Coding!
7 Lectures 33:44
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.

Preview 04:39

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.

Preview 06:23

We'll add a “bouncy” material to the beachball and discover how to create prefabs, or prefabricated game objects.

Bouncy Material and Prefab 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.

More Material, Play Time, and Saving the Scene

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!
Troubleshooting - Vanishing Assets!

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.
Sorting Layers - The Real Answer to Vanishing Assets

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

Physics Components
5 questions
Some Easy Scripting for Unity
4 Lectures 16:14

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.

What About Coding and Scripts?

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.

Preview 03:18

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.

Preview 06:54

Your First Script: Picking Up A Coin (Part 2 of 2)

Simple Scripting
5 questions
Diving Deeper Into Scripting
8 Lectures 53:08

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.

Tagged Objects and IF 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!

Create the New Scene

Here we'll create a simple script that will be added to our bomb prefabs.

The BombHit Script

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.

Interactivity with Mouse Clicks

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.

Cloneliness is Next to Godliness

Now that we can instantiate, I want to instantiate all the time, 24/7! So let's discover the secret formula for that…

Thank You Sir, May I Have Another? InvokeRepeating()

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.

Static Variables and Functions, Yikes!

More Scripting
5 questions
Sprite Animation
7 Lectures 41:44

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.

Animation with Rigidbody2D.AddForce()

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.

A New and Improved MoveObject Script

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!

Keyboard-Controlled Animation

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.

An Introduction to Sprite Sheets

Let's dive into using sprite sheet animation in Unity.

Animation Using A Sprite Sheet (Part 1 of 2)

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.

A Quick(ish) Mini-Game

Animation Quiz
5 questions
Audio and Visual Effects
9 Lectures 36:04

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.

An Introduction to Particles

Let's create a simple particle effect that will be triggered when we pick up a coin.

Creating A Pickup Particle Effect

Want to save time? Grab some pre-made particle effects.

Downloading and Importing Particles

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.

Using Particles In Your Game

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

Import Audio Into Unity

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.

Add Background Music to a Scene

Let's add a sound effect when the player picks up a coin. Those little touches can really add a lot to your game.

Sound Effects on Prefabs

So far all our game objects have been visible, but using invisible objects can be really handy at times.

Trigger Audio with Invisible Game Objects

Small Code Change! (Read This!)

Particles and Audio Quiz
5 questions
User Interface
9 Lectures 36:19

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.

Creating Text Elements

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.

Jay is Flawed: The UI Scene View Fix

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.

Using Custom Fonts

Add a button to our game.

Creating a Button

Now let's see how easy it is to hook the button up to pieces of our project.

Using the Button's OnClick

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!

Intro to the Sample Project

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.

The Missile Script

Using a button to enable and disable a game object component.

Enabling Components

Let's add some simple scoring to the game.

Adding Scoring

User Interface Quiz
5 questions
7 Lectures 47:38

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

Rolling Along with Wheel Joint 2D

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.

Motorizing the Wheels

Here's a function that can be used in many games -- make the camera follow whatever game object you choose.

Camera Follows Game Object

We need more friction on the tires so we can pop some wheelies!

Adding Friction to the Tires

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.

Optimize the Code

Let's put some pieces together in order to get ready for our monster truck mini-game.

Getting Ready for the Mini-Game

Building the monster truck mini-game.

Monster Truck Mini-Game
Your Final Project
3 Lectures 07:34

The "Cheat Sheet" referenced in the next video is the Final Project API Calls document here in the Resources section.

Putting It All Together

The PDF document referenced in this video is the one you should have downloaded from the Resources section of the previous lecture.

A Unity Cheat Sheet

Where you can find free-to-use art assets for your own games.

Art Assets for Your Game
About the Instructor
J. A. Whye
4.5 Average rating
4,973 Reviews
113,220 Students
7 Courses
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.