Important Notice:

On July 31st, 2017 the Digital-Tutors library will be retired along with Digital-Tutors concurrent licensing. Effective August 1, 2017 any active group plans will be redirected to www.pluralsight.com. Each group plan will receive one individual user license on Pluralsight for each active Digital-Tutors license. Please contact your account representative for any additional questions.
Parenting the character
See Details
Joshua Kinney

Pluralsight

Joshua Kinney
In this lesson, we're going to begin rigging the character. All right, so I said that we're going to be rigging the character, and I don't want you to be confused, because there aren't any new tools as far as rigging 2D characters, or anything like that. Really, it's just a matter of parenting the character properly, and setting it up properly. We've brought in all of the pieces, and we set up all the parts to where they're overlapping properly, and it looks as though it's being drawn properly. OK, that's all fine. The issue that we have now is, how do we get it to animate. Well, first thing that we're going to do is we're going to go ahead and we're going to create a new empty game object. We're going to rename this to character. Or you can name it zombie, or something like that if you like. I'm going to take this game object, and I'm going to center it up on my character. And I'm going to put it right here, along the belt line of the character. And with that set, just like that, we're going to take all of the elements of our character minus that character object, and parent those to this game object. So I'm going to select around everything there. We should have, it says 15 of 16 objects selected. Let's go ahead and try that one more time, just like so. We've got all of those sprites selected there. Let's come in, and let's hold down control. OK we don't have that character selected, that's good. OK. So we've got leg upper. Let me move that around, make sure that is all of the character. Hit control-Z one time to back to its original position. And we're going to drag and drop those pieces on to the character. So now that is parented to that object. So let's select just the character object, and we can move that, and that moves the entire character now. But now what we want to be able to do is we want to move the individual pieces of the character. So if I select the head, I want to be able to rotate it, to create animation. Now you can see here if I come in and I rotate that, you can see that nothing else is parented. Now, really quickly, we don't want to rotate using the Rotate tool. We want to rotate using the Move tool, but we're going to rotate it like this. We're going to hover over the outside corner of the sprite box, and then we could rotate that way. So here you can see that that looks more natural. But you see the eye stays behind, as well as the eyebrows. So what we need to do here is we need to parent the eyes, or the eye and the eyebrows to the head. So we're going to eye and eyebrows. We're going to drag those on top of head. And then if we just select the head, and we hover over the corner, you can see how the icon changes. Now we've got that rotation. That looks great. Now we want to take the body, and we want to be able to rotate it. Just like so. But we want the arms, and we also want the head to come along with that. So let's take the arms, or actually let's take the head first, and let's attach that to the body. So we're left-clicking and dragging that on top of the body. So if I select it, and I rotate it, you could see the head comes along. Now I still have full control over the head itself, and everything else works as it should Let's go ahead and rig up the arms. So let's select the upper arm left. Actually let's take the upper, or the lower arm left, and let's drag that on top of the arm upper left there. So that's parented. So if I rotate that, you can see both pieces come along with it. But then I have the ability to take the lower arm, and rotate it. Perfect. Let's do the same thing for the other arm. So lower to upper, OK. Now we also have the hand here, so we don't want to forget it. The hand needs to go on to the arm lower right. So that's parented there. So if I select this object, parent, move it around, you could see that everything moves along with it. Take the lower arm, that rotates, take the hand, and that rotates on its own. Perfect. So here we have the upper body, now we need the lower body. Now what I'm going to do here is I'm going to parent the legs to the undies there. So let's do the legs first. We're going to have this leg, that's leg upper. Let's go ahead and rename it to legupper_right. And let's take this one, we're make that leglower_right. An then we're going to say foot_right, or r. Perfect. Now let's do the next one. Let's do underscore left. And we just want to make sure that we're staying consistent with our naming convention. Now it's much easier to see, and that's going to be easier to parent. So let's go to foot right, and we're going to parent that to the leg lower right. Leg lower right to leg upper right. And then we can come in, and we could check that out. That looks good. And we know that everything else is parented as it should be. If you want to do a check on that, you're more than welcome to. Now let's do the same thing for the other leg. So we're going to do foot left onto leg lower. Leg lower to leg upper. Check that one, and that one's good. And then now we want those legs to be attached to the undies. So we're going to take both of those legs, we're going to left-click and drag those onto the undies. And then now I can take that, and I can rotate those just like so. All right, awesome. So now you're seeing that we have these main pieces here. Let's go ahead and take the arms, and put those onto the body. And now the character's made up of the body, and then the undies. You could rename that to upper and lower half, if you wanted to, to make it a little bit easier on yourself. But I know that everything is attached properly. So now I am ready for animation here. I am keeping these separated for a reason, because if I wanted to do an upper body movement, without adjusting the lower, I'm able to do that. And then same thing here. So if I wanted to do something like a jump to where the undies kind of come up like that, and then we adjust the legs, we're free to do so. But it's all put together by this character. Now it looks like our character object got reset there. So what I'm going to do here is I'm actually going to place this right on this grid point here, just like so, and then I'm going to take the body and the undies, and I'm going to move that right over this top of that cross-hair. So sometimes that may happen. Actually, looks like that's getting taken away. Ah. OK, the reason that it's doing that is because the body is parented, and it's got many other objects in there. So we're not going to be able to get around that. So let's go ahead and let's just reset all of this. So we're going to reset that to 0,0 and that's going to bring it right up here. And then we can drop this down. And there our zombie is in our level. So you can see that his feet are below the grass, and that's exactly what I wanted. I don't want it to be right on top, or anything like that. So everything looks pretty good right here. So I'm happy with the way that's looking. And in the next lesson what we want to do is we want to get into creating our collisions for our character. And this is going to take a little bit of time to set up. Because now we have to think about how we want this character to move and interact. And then we'll also do a little bit of clean-up on our level, before we end that next lesson. So we'll get started with that next.
In this series of training we will discuss the major components of working with the 2D features in Unity. We'll start off by learning how to set up a 2D Unity project. Then we'll learn how to properly import and slice our sprites. After that we'll learn how to manipulate sprites by blocking in a simple platform level and also learn the importance of Sorting Layers.

Then we'll jump into the real fun by assembling, parenting and animating a character. By the end of this tutorial, you will have a better understanding of working with Unity's 2D features.
Introduction and project overview
1

Introduction and project overview

 
00:45
Setting up a 2D Unity project
2

Setting up a 2D Unity project

 
13:05
Manipulating sprites
3

Manipulating sprites

 
14:03
Setting up props
4

Setting up props

 
13:35
Slicing the character
5

Slicing the character

 
13:57
Parenting the character
6

Parenting the character

 
09:25
Creating the colliders
7

Creating the colliders

 
11:10
Creating the idle animation
8

Creating the idle animation

 
17:31
Blocking in the walk cycle
9

Blocking in the walk cycle

 
11:50
Finishing the walk cycle
10

Finishing the walk cycle

 
08:06
Setting up the animations
11

Setting up the animations

 
04:49
Scripting the movement
12

Scripting the movement

 
12:55
Using sprite sheets for animation
13

Using sprite sheets for animation

 
07:48