Join Sue Blackman for an in-depth discussion in this video Importing characters and setting scale, part of Animating Characters with Mecanim in Unity 3D.
- View Offline
Let's start by creating a new project in Unity. I'm going to go to File > New Project and navigate out to my Desktop and to My Exercise Files folder, chapter 1, 101, and I'm going to create a new folder. And name it Mecanim Course, and that is the project name. Select folder, and now we're going to need a few packages, we need character controller and we need a script. And because we're going to be needing some textures, lets also bring in the terrain assets, and create.
Now the first thing I like to do is I like to change my setup. From the default to the two by three. I also prefer the single column project view. You can get to that by right-clicking and choosing One Column Layout but feel free to use whatever you're comfortable with. Now, let's go ahead and save our scene, File > Save Scene as, and we'll just name this one Character set-up. And next we'll need some test subjects. So I'm going to go out to My Desktop.
In the Exercise Assets folder, you'll find the Characters folder. Let's open it up and see what we've got. We've got several FBX files of characters, and a few PSD files for their textures. So this folder contains a few characters that were created in 3ds max, but were exported as fpx files. Unity can read files directly from several different modeling applications such as 3Ds Max and mia, blender and several more, but internally it still converts them to the FBX format.
If you don't have the native application installed and licensed in your machine you may not be able to read them in. Exporting to the FBX format ensures that anyone will be able to read the files into unity... So let's go head back to our exercise. Assets, copy the characters folder, then we'll paste it into the Unity Project folder's Assets folder. Now when we go back to unity, in the Project view, we can see our new folder.
And the contents. Notice that unity doesn't show us the file format anymore. The blue box icon shows that it is an asset. If we open it up, we can see that it contains all the parts that came along with that FBX file. So the first thing I want to do once I've brought in new assets, expecially characters, is I want to check their scale. And to do that, I want to set up a nice little plane. And then I want to set a cube in it, so I'm going to go to GameObject > Create Other > Plane. This'll give me a ground plane.
And then I'm going to Create Other > Cube, and focus in on it. Now, this guy, because Unity uses meters, if we look at his scale, he's 1 by one by one. In Unity when we create a character, a normal sort of six foot high person would be about two meters tall, so characters we want to be somewhere between This height and double it. I'm going to go ahead and change the Y scale so we can see a good generic height for the character.
And now we can bring our characters in, so I'm going to drag the assets in one at a time... This guy's obviously too small. Delores, on the other hand, is way too big. And we'll bring Linny in. And he's not too far off. And I'm going to bring one more, and that's the robot character. So, there's three main types of character setups that you can bring into Mecanim.
Traditional-skinned characters Like Lenny here where the bones effect the mesh or skin. Multi part hierarchical characters like robots, where the parts are rigid but all linked, and pure bone systems without any meshes at all. These contain just animations, and we have a little bit of everything in this folder... The reason why we want to deal with scale first is because even though Unity is very good about scaling complex hierarchies, once a character's been configured, changing the scale will mean having to reconfigure the character.
So we always want to check the scale first. I already know how big I want my characters to be. Box man we're going to us as an example for the scaling problem later on. So let's set him to .04. We select him in the project view, the asset itself and in model, .04 and apply Delores needs to be point zero, zero, zero four five and apply. Lenny needs to be 0.0075 and the robot needs to be 0.03. And once again, we apply.
Lenny still looks a little bit tall, so I'm going to check my cube, and sure enough, I forgot to bring it up. After I changed its scale. So everything looks pretty good right now. So these guys needed to be scaled because they've come in from a bunch of different projects and different places and different times. If your bringing in assets from you this asset store there scales are probably going to be correct. Then again you may want to change the scale of the character depending on what type of character he is.
So with the scales all sorted out, in the next video, we'll start configuring the characters.
- Importing characters and setting scale
- Setting up the controller
- Creating transitions
- Scripting the controls
- Adding layers and layer masks
- Handling nonhumanoid appendages
- Configuring blend trees
- Controlling states with speed
- Adding a multistate jump
- Targeting with IK (inverse kinematics)
- Setting up generic rigs
- Testing the character in the game