Hi! My name is Gustavo Carvalho from Contra Labs
And this is how to make sprite animations with Unity 4.3
Using 2D native development
So, let's get started
Let's create a new project
I will make it "Animation Sprite 2D"
And here I will use nothing of this
But I will set up defaults for 2D
And "Create Project"
So, now we have this 2D option over here
Where we can see the scene in a 2D way
We have our camera, which must be set to 'orthographic'
Because you are dealing with 2D
Let's put a new sprite here
Unity 4.3 has this new kind of object called "Sprite"
Which contains the "Sprite Renderer"
Now we must create the images that will be used by our sprites
Let's create a folder called "Sprites" and put our sprites there
We can put the sprites separately or we can use a sprite sheet, like this
I will use this sprite sheet over here, let's make it into sprites folder
This is a kind of "Sprite"
The Sprite Mode is "Multiple" because I'm using a sprite sheet
And I can open the Sprite Editor to choose each one of the sprites I will use
So, before this I got this warning telling me that if I use a compressed texture
it will give imperfect results
So I will change the mode from "Compressed" to "Truecolor"
And Filter Mode I will change it to "Point"
If you are a beginner probably you want to use this as well
But if you are advanced you can choose better your configurations
So now open you Sprite Editor
Let's choose here...
Still got this warning because I think I did not apply this
I can open the editor again and slice it automatically using the automatic mode
I can use Minimum Size of 10 pixels because I know that every image I have
Is at least 10 pixels wider or taller
And the Pivot point I will use the bottom
I got this sliced and here I have all my images separately one by one
I can edit the options of each one, move the pivot or size
The pivot is this little ball, I can put whatever I want
I will leave at the bottom
"Apply" and now I have each one of the images separately
Now all I have to do is select my sprite object
That I created here and move the selected animation frame that I want
So for now I want it to walk so I will select this sprites and move it
To animation screen
I will put a name for my animation - Walking
And I will save it in a new folder called Animations
Save it. If you don't have the Animation window you can open it in Window -> Animation
So now you have this.
So if you go to you scene view you can see your sprite over here
And if you play it, it is animating but it is too fast, so you can
adjust the speed of animation to 12 and now looks better
And that is the way you do sprite animation in Unity
If you don't have a sprite sheet like this you could use separated images
It work in the same way, just select the images and drag and you have the animation done
But, how you can do separated animation?
If you go here in Animations (folder) it created an Animator called "New Sprite"
Which controls the animations and we have this specific animation which controls the walking
Now, if you go here and create a new animation (New Clip)
Let's say... "Running"
I will save it here as well
Now I have our Running animation and will configure this
running animation to use this sprites over here
So now i have a running animation and I have a walk animation
Walking and running
Here again I will change the speed to 12
And now it looks better
But, how can I change from one animation to another?
If I open here the New Sprite it will open a Animator window
And as you can see we have a Running and a Walking state
So the start state or the default state is that orange one
And from here I can choose to go to other states of animation
The way I can do this is make a transition and I have to configure
what makes this transition, what conditions trigger the transition
Now I only have this condition, "Exit time", so when this first animation is done
it goes to the next animation. But if I use some parameter here
I could create any parameter here
For exemple, "StartRunning", so now that I have this parameter I can go into the code
And say that animator.SetParameter("StartRunning", true);
So when the code tells the animator that StartRunning is true, then the transition will happen
But for now I will just use the Exit Time
But let's suppose I don't want the Walking running only once, I want it run twice
So after it run twice the character can "Running"
So let's test it to see if it is working or not
So now, as you can see, it is running, but I didn't see the transition
Let's start over. I think the transition from walking is too fast
But if you go really slow you can see it starting in walking and then
Moves to Running
And that it. A simple way to do sprite animations with Unity 4.3
Bye