From the course: Cert Prep: Unity Certified Associate Game Developer Animation and Cinematics
Humanoid animations and configuration - Unity Tutorial
From the course: Cert Prep: Unity Certified Associate Game Developer Animation and Cinematics
Humanoid animations and configuration
- [Instructor] In this movie, we're going to work with the Unity humanoid system that's part of Mecanim. The broader character animation system. We'll see how to configure that character and get it up and running in this scene. Let's take a look at the character we'll be using. Here inside the project panel, inside the robot Kyle folder. Inside the model folder, you'll find the Kyle robot, which is also available completely free from the Unity Asset Store. It's a robot character, and I'm looking at it here inside the project panel and the object inspector. If this is the first time that you're importing this model, then it may be set up slightly differently to what I have done here and which is included inside the exercise files. When you select the robot Kyle model, and you switch to the rig tab. When you move to the animation dropdown, the rig will be none, legacy, or generic but it probably won't be humanoid. In this case it does have a humanoid rig. So I've selected humanoid here. Whenever you have the ability to switch to that humanoid rig for a character, you should always try to do so. A humanoid rig is just the configuration of bones within the character model. If your character has two legs, two arms, a body and a head, then it has the humanoid morphology. And if your character, artist and animator has configured it with the relevant bones inside the 3D modeling software, then you should be able to choose humanoid. When you select humanoid and you choose apply, next to the configure button here, you should be greeted by a big tick. This indicates that Unity has successfully identified all of the bones inside this character model. It might have a cross instead meaning that Unity has not identified all of the bones. Either way you can check out the configuration of the character model just by hitting the configure button. Now, when you do that, it may ask you if you want to save the changes in the scene and you need to click either yes or no depending on whether you do. In my case I don't need to worry about those changes. If I switch over to the scene tab, you can see that it's taken me to a detailed view of the character where it's highlighting the bones that it's been assigned here in green. On the left-hand side in the hierarchy panel, you can see the actual bone objects that's been assigned to the character by the animator in the 3D modeling software. You can also see the different names that they've assigned to those bones. On the right-hand side in the inspector here, we have what Unity calls the avatar which is a special character asset. You can already see here in the project panel that it has a default character avatar. The avatar is just a map of the human body in its humanoid form. And in each of these different slots by left clicking, it actually selects different bones inside the model that is associated with that area of the body. The upper arm is linked to the upper arm bone and so on and so forth. If your configuration was not successfully detected on the rig tab, you might need to drag and drop the bones into the relevant fields to ensure all of these slots are populated with the relevant bones. In the cases like these the chest where we have the dotted circles, it simply means that these fields are optional bones. You can see this in the key here. We also have access to the muscles in the settings tab that you can switch to. To see how this current configuration of the bones will deform the character in different poses. So we have some common preset poses up here, for example, the open and the close pose. And when I move that to the right and to the left, the character gets contorted and stretched to different poses where we can see the influence of different bones inside the body. For now I'm just going to choose done to exit the editor. I didn't need to make any changes because by the configure button we had that tick icon to indicate that this model was already successfully configured. All I need to do now is just drag and drop the character model into the scene. And again, the character is set up and it's looking absolutely fine. I can hit play on the tool bar and when I do the character would just be standing stationary on the spot here. Now, to play animations on this character, because it's a humanoid, we don't need to have dedicated animations for this character. We can reuse animations that work on other humanoid characters. To demonstrate this, I'm going to go back to the assets folder and scroll down to the standard assets folder here in the project panel. By double clicking that, and following the folder structure here from characters. Third person character and animation, you'll see a list of different animations. I can stretch this to the left to see the list of the animations and their names such as the idle or the run or the walk. When I left click to select those and switch to the animation tab, I can press the play button on the toolbar. You can see we have a walk animation. Notice this walk animation is being applied to a character, but it's completely different to the Kyle robot. If I switch to the rig tab, you can see this is listed as a humanoid animation too. This means the animation on these humanoid characters can be repurposed for the Kyle robot and to do that is really, really easy. In fact, in the earlier movies of configuring our original Lemon character, we already have the process refined and we saw how to do that. I'm going to go back to the assets tab here and I'm going to create a new animator controller. Let's just increase the size of these thumbnails. I'm going to right-click create, and then simply choose animator controller. And this time I'm going to call it anim robot. Or actually let me just spell correctly I'm going to rename that to robot like so, and then I'm going to select the robot Kyle here in the hierarchy panel and drag and drop my anim robot into the controller field as we did previously. By double-clicking on the anim robot, it brings back the animator component. This allows me to scroll down to select the animations here that are for a completely different character. For example, in this case, I'm going to grab the idle animation and drag and drop the humanoid idle into the animated component here, move back to the game tab and press play. And notice impressing play what we have done here is we have reused a character animation on a different model to this Kyle robot here. And if you check out the Unity Asset Store for example for the FBX Mocap Library, you will see that there are hundreds and thousands of character animations that you can download, integrate into your projects and use to animate humanoid characters. That is really powerful stuff.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.