Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Animating in 2D in Unity is just like animating in 3D. We've got great control with the dope sheet and curve editor over our animation. What I'll do to start out, before I animate the car, is parrot all these cars in their background under an empty game object, and get them into place, so that when I key position, it's in the right place, and the cars don't jump around. I'll start out by choosing Game Object, and Create Empty. I'll name this empty game object art cave schematic cars. And now I'll use the hierarchy view to parent those cars under that game object.
I'll roll up the art S and select those car elements. I'll drag them right under R K and now they're parented in. Now I'll move this into place in the view. Getting out of my 2D window and pulling it down into the scene. I'll switch over to a wire frame, and I'm going to pull these cars right down into the building by the I've pulled my cars into the view, and I'm ready to get the animation on that lead car. As a note, if you're moving your 2D around and rotating it or positioning in the space, you may want to hold off on the colliders, until you're all ready.
Once that 2D is finally in place, and it may be even parented under, then get the colliders on. 2D colliders rotate oddly when they're parented under things, so be careful the order you're working in. Now I'll animate that car. I'll select that lead car and pull up my animation window, choosing window and animation. We can work in either the dope sheet or the curves depending on which way you'd like to start. With either one I'll create an animation clip first. Simply clicking over on the time line creates one. And I'll name this new animation clip car move.
I'll put it in the assets animation folder. I'll click Save and it's made the new car animation file, now I'll animate this car. First by pulling it over and then adjusting the keys. I'll pull the car over just enough to bunk into the car in front of it, this should trigger those physics. Now go into the Curves menu, and there's those curves. They're actually very slight. If we look at the position X we can see it's really not a big jump.
I'm going to play with the curves just a little bit. What I'll do is let the car start out slow, and accelerate into motion. I'll pick that key at the end. Right click and choose flat tangents. This way, I can adjust that handle, and I'll make it a sharp-in. Then I'll pick the key in the beginning and flatten out that tangent as well, making sure to right click straight on the key. If you don't, you'll add another key as you just saw that Menu pop up. I'll choose flat, and just pull that handle a little bit. Now the car starts fairly slowly, zooms into motion and will smack into the other car.
We can see in there that the car actually keyed all three axes. We just didn't have any motion on the wire Z, it was only an X move. Now this animation is ready, and I can put on either an animation controller and an activate trigger on the box collider in front of it. Or, I can use mechanin. It's up to you which you'd like to do. The 2D elements tie beautifully into mechanime as well and so if you want to do a 2D game with all kinds of behavioral states you can put that in. Just simply swapping out your 3D elements and 3D character for your 2D sprites.
Get unlimited access to all courses for just $25/month.Become a member
100 Video lessons · 8569 Viewers
94 Video lessons · 26775 Viewers
107 Video lessons · 37418 Viewers
147 Video lessons · 6196 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.