Unity 3D Game Development Mecanim Animation System explained

Source: Internet
Author: User

This tutorial and you share Mecanim animation system redirection features, Mecanim animation system is Unity3d launched a new animation system, with redirection, can be fused and many new features, through the close cooperation with the artists, can help the program designers to quickly design character animation. Follow the popular blogger Qin Yuanpei to learn it!
Bloggers want to share with you today is the Mecanim animation system redirection characteristics, we all know, "Paladin biography" is a classic RPG game, the game to today is still glowing with a strong vitality. Bloggers on the Internet to know a production "Paladin biography" fan game small team, they are currently working to produce a "Paladin biography Five: Wish" of the fan game, the game based on Unity3d, because of technical consistency, bloggers asked them some game material, This became the main reason for bloggers ' determination to study the Mecanim animation system. is a "Chinese Paladin five prequel" in the flaw of a model:

To get this model, Bo master found that the model of all the animation is placed in a animationclip, so the blogger decisively will this animation file segmentation, segmentation method is found in the resource directory of this animationclip, Then, in the Properties window on the right, select the Animations tab to create a new anmationclip with the + sign, and then implement the segmentation of the animation after you have specified the start frame and end frame number. The list of animated files after the blogger has been segmented:

You can see that the blogger has segmented a cartoon segment into 4 animated segments, so that we can play the animation by animation components. This is precisely the animation control form that Unity3d used before the Mecanim animation system was introduced. Because this model in the modeling of the time there is a problem, so that the defect in the game scene in the angle of error, Bo Master had to use 3D modeling software to adjust, the results unexpectedly found that the model is skeleton, Bo Master suddenly thought of a problem, Can I use the Mecanim animation system to animate this model? The answer is yes. Since this model is modeled with the animation and the model created together, we need to first remove this animation from the model, because one of the main ideas of the Mecanim animation system is that a set of animations can be applied to different models by redirection, since there are animations available, Then the animation of the model can be temporarily removed. The way to remove the animation from the model is simple, is to export the FBX model when the embedded media options do not tick, so that our model can be separated from the animation, after this step, we formally began to Mecanim animation system explained. To understand the Mecanim animation system, there are several concepts that need to be understood first:
One, Avater, Avatar, this is an interface to implement animation bindings in the Mecanim animation system, which enables the matching of skeletal and muscular systems, thus ensuring that characters are able to move in a pre-set animation as they perform animations. We first found the model file in the Project resource window,

We notice that there are three tabs in the Properties window on the right: Model, Rig, animations. Here we select the Rig tab and set the animation type to humanoid, which is a biped type animation. This type can support most humanoid models of the class. In addition, the Lagacy type is designed to be compatible with model animations in the Unity3d lower version, which is a common type between humanoid and non-humanoid models. After we select the humanoid type, select the type to generate Avater below the Create Form this model, which generates a avater from the current model. At this point, the Configure button from the unavailable state into a usable state, we click the button, if we do not save the game scene, this time Unity3d will prompt us to save the scene, we directly choose to save, then open a new scene,

The skeleton structure of the model is displayed in the scene, corresponding to the main body structure of the model in the right window, and you can see that all points in the right window are shown in green at this point, indicating that the current model's bone joint and model match correctly. At this point, we can switch to the Muscles tab, which is where we can check whether the model matches correctly by dragging the sliders. When using Avater, there are two points to note:
1, if the model modeling is not a serious error, you can use the mipping->automap at the bottom of the window to achieve automatic matching of the model, which can improve the efficiency, but as a moral integrity developer, we must not be overly dependent on this feature.
2, when the manual adjustment model matching, if prompted T-pose error, can be Pose->enforce t-pose to achieve forced conversion, Bo Master recently began to learn game modeling, so here may not explain clearly, we as a lesson from the experience.
After confirming that the model matches no problem, click Done to finish editing.
Second, Animatorcontroller: If say Avater is the body and skeleton of the model to achieve matching interface, then Animatorcontroller is to talk about animation and model to implement the interface of the binding. We create a xiaanimatercontroller here. Double-clicking the file opens the animator window,

Bloggers do not want to introduce in detail the concepts of state machines and hybrid trees in the Unity3d animation system, as these concepts are now difficult to explain, and bloggers intend to put them in the next article to explain in detail the concept of the state machine and the hybrid tree of the Mecanim animation. Today we just do a preliminary understanding of Mecanim animation system, because to thoroughly understand this animation system, is not overnight of the work ah. The blogger creates 6 animated states here and connects them with a line with arrows. What do bloggers want to accomplish here? Bloggers hope that under certain conditions can trigger the corresponding conditions, when the departure is completed immediately after the default state, where the default state is idle. It is estimated that people will be a bit confusing here, Bo Master is not to say that this model does not have animation, then this animation is where? In this case, bloggers here to explain Ah, the blogger before the creation of this project, the early preparation of a animation package called Womanknightanimationpack, which provides the game in the common animation, We are here to use the Mecanim redirection feature to apply this animation to our model, which can be downloaded from the official resource store. OK, now let's talk about animation and model binding, we click the default idle animation, and the following appears on the right side of the window:

With the motion text box we can bind an animation for the current state, check the foot IK and mirror options, seem to be able to solve the role in the walk or run the problem, but bloggers in the API documentation is not found in the relevant explanation, if a friend knows, I hope you can tell the blogger. Similarly, we can bind a cartoon segment for different states, but the question is coming again, how do we play the corresponding animation in the right time according to the game plan? This is the animation trigger problem, bloggers Please think about the concept of finite state machine, if you do not know the concept, please understand, this is a game design is very important, very useful concept. We know that in a finite state machine, whether we use the switch-case structure or the IF-ELSE structure, we need a state value as the basis for judgment, then this principle still applies in mecanim. Because, Mecanim animation system is based on the state machine. OK, let's create a status value. ,

In the Mecanim animation system, there are four types of state values, float, Int, Bool, Trigger, where the Trigger and Ontrigger () methods can be used to implement the triggering animation. Okay, now we're going to create an integer state value with a default value of 0. We first select the Idle->walk route, set the parameter to ActionId in the window on the right, set the value to 1, and set the method to equals, meaning that the walk animation will be performed when the value of ActionId is 1 o'clock. Likewise, we will walk->idle this route, set the parameter to ActionId, set the value to 0, and set the method to equals, meaning that the idle animation will be executed when the value of ActionId is 1 o'clock. The rest of the animation state parameters and the walk setting method is the same, from the idle line is 1,2,3,4,5, pointing to the idle route is all 0. Now let's assign this animatorcontroller to the model in the scene,

At this point we run the program, because we have specified the default animation for the flaw, so we will see:

Although this animation and our flaw sister with a bit vainly disobey, but we have initially mastered the use of Mecanim animation system, OK, let's write a script to control the character switching animation, because only the default animation is not practical use:

Finally, let's look at the actual results together!

The terrain in the scene is created by Unity3d's own terrain tool, in fact Bo is trying to build a "Chinese paladin five prequel" in the Cloud to the stone scene, because Bo Master firmly believe that with Jin Xuan's wisdom can not imagine in and the flaw both fell cliff after summon cloud to Stone, so Bo Master firmly believe that they are not dead, Because Twilight elder sister finally looked back at the instant expression is joyful, and behind came a hurry a slow two footsteps sound, so the end everyone can imagine. In the game "Paladin Five after the biography: Wish" in their plot and Bo master of the Basic agreement, perhaps this is the "Chinese Paladin Biography" series of games so that bloggers have been willing to optimistic, and strive to go down the reason, we are ordinary people, but we are not because of ordinary and ordinary, but we chose not to act. Before Bo Master heard of a game launched by the Paladin player "Paladin four: Back to the beginning", at that time to see the game propaganda animation excited for a while, but to later this game because of the dissolution of the production team to announce the stop, it seems always reminiscent of the past of Shanghai soft Star. Careful friend must have found the Bo master used material is the model of the Chinese paladin, you can find this model is relatively simple, the tree is basically a piece of paper, the Shadow is created in the model, the year Shangchang led soft-made Paladin three, the Chinese paladin Three, Chinese paladin four difficult degree can be seen. However, the current from the backbone of the soft core of the Shanghai Dragon has come out of the plight of the year, and Daewoo double sword to contend with the third sword. For Bo He the Lord always loves the sword? Because the legend of the Sword, until eternity.

Unity 3D Game Development Mecanim Animation System explained

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.