The first in a series of tutorials on how to make a 2D PC Game with Unity3D. This tutorial will stop at animating an Idle sprite that just does the same thing over and over. If you want it to be interactive, that will be in "Part 2: Animation and Basic Physics"

Packages

None. Don't use any of the packages that come with Unity if you're making a 2D game because all of them are meant for 3D games and won't be very helpful when working with 2D.

Make sure to set "Setup defaults for" to 2D

 

If you want to use the same sprites as me, go ahead. It's not like they were hard for me to make.


The Hardest Part

REMEMBER TO SAVE THE SCENE.
I made 3 folders. One for Sprites, one for Scripts, and one for GUI
Everything should be in the assets folder or a sub-folder of it, like Sprites.
Plop your sprite sheet into one of the folders you made.


Sprite Settings

Once you've clicked your sprite, you'll get this in the inspector tab

For animated sprites, set Sprite Mode to Multiple. For now, basically just play around with the settings below Texture Type to get it to look right.

 

Filter Mode is for Anti-Aliasing and can make your sprite look awesome or horrible depending on your game's resolution and the sprite's resolution.

 

Max Size is for when you have a large image.
e.g: If your sprite sheet is less than 32x32, set it to 32.
If it's between 256x and 512x, set it to 512.

 

Format is how it handles the colors. If the colors don't look right at compressed, set it to Truecolor.


The Sprite Editor

Click on Sprite Editor in the inspector and you get this awesome thing.

This is amazing. With RPG Maker you have to align the sprites perfectly and the number of sprites per sheet is limited. Not with Unity. Unity is awesome like that.

 

First, click on slice and set type to grid. If the sprites are already aligned, set the pixel size to the size of each individual sprite.
If it's not perfectly aligned, or you're not sure if it is, you can actually select, move, and resize the grid squares. The blob above is aligned to a 24x24 grid, so if you're using that blob, set the pixel size to 24x24.
Once each sprite has it's own box, click apply and then the little x in the corner.

 


Creating a Game Object

There are a couple ways to make game objects, but probably the easiest way is to drag and drop the image of what you want it to look like onto the scene.
To choose a specific sprite from the sheet, click the arrow on it to expand a list of sprites.

 

After your game object is created, double click on it in the hierarchy so you can see the sprite perfectly.

 

You'll also get this in the inspector when the object is selected.

What most of this stuff does should be obvious and, in this tutorial, all you'll need to mess with is the Add Component button and any components you add.


Making an Animator Controller and Controlling an Animation With Said Controller

Click the big "Add Component" Button, then Miscellaneous, then Animator.

 

Next, go to the top of the Unity window and click on Window. In the drop down menu, click Animator and Animation. Place them wherever they're convenient.
Now go look at your Animation tab.
Make sure the game object you're animating is still selected.

 

Click on the first sprite of the animation(In the Project tab), then Ctrl+Click the others to select all of them. If they're all in a row, just Click the first, then Shift+Click the last one.

 

Drag and drop the sprites onto the part with all the lines. Make an Animations folder if you want and name the animation. Like Jeff or something.
This will happen, and something cool will happen in the Animator tab, which I'll get to in a second.

Set Sample to the number of frames per second. This is usually NOT the same as your game's FPS. That blob I used looks best at 4, for example.


What All That Did

The Animator tab should look like this.

 

All you have to do now is align the Main Camera game object so it can see the blob, then click on the play button to see something like this:

 

And that's about it.
Part 2 will go over how to make a controllable AND animated object.
There WILL be coding. Lot's.

Share


About the Author

No Comments

Quick Reply

Guest

Enter a username

Security check: What is 8 plus 2?