Unity animation Knowledge of the second: Animator Animation state machine

Source: Internet
Author: User
Tags new set

Last time we talked about unity game animation from getting started to being hospitalized, let's talk about animation state machine today.

OK, now we have successfully imported the animation. The next thing to play is 13. Because most animators don't use this guy, they need to master the skill, at least the animation leader level. Well... A group of only you one animated, shut up! Give you a sympathetic eye.


This fork thing is an animated state machine.

Well ~ There must be an unknown truth to eat melon masses to ask, this thing in addition to install B can also use. State machine, provides the transition between animation states, with animation fusion, can edit the logical order of animation playback, can set random play, can set the behavior tree. The active animation state machine was published in the 4.0 version, compared to his previous generation. That's the difference between a bip bone and a bone skeleton.

First, we're going to create a new state machine. Under the Project panel, click Create to locate the animator controller, press F2 to start the state machine, and double-click it to enter the state machine panel. Or, in the Windows window, locate animator to open the state machine panel.


Drag a well-done animation into the state machine panel, or right-click Create State→empty creates an empty state, specifying the animation in the Properties Panel motion property Bar.


Then we introduce the Inspector (property panel) content of the gray rectangular state machine.

Naming does not explain

Tag tag

Motion said before that it was the place to specify the animation

The speed of speed animation is played in multiples of

The mirror image is no different from the image on the animation system.

Cycle Offset loop Offset amount seems to be the number of cycles set

These three parameters have parameter this option, which is the use of animated parameters set

Foot ik foot ik

Write Defaults writing presets


Creates a series of gray rectangle states, right-click Make transition to specify a connection relationship between state machines


Check the line, you will find that the connection is also a property set. Mixed's action fusion is here to set

Accept interrupt time check to wait until the current animation has finished playing, the next state will be followed. If you do not tick, you will be interrupted when half of the animation is played. Here is a brief introduction to the following parameters, the actual operation of the process you naturally understand what it means ... setings set, exit Time interrupt (from which frame to gradually decrease the weight of the current animation), Fixed duration constant duration (This is actually a toggle switch, Whether the toggle is displayed in seconds or as a percentage), transition duration over duration (over how long), transition offset over offset (from where the next animation starts), interruption SOURCE interrupt.


Let's show you a relatively simple animation state machine, where the orange standby animation is the initial state, all other states need to start from here, also can return here. This is the least demanding of the planning baby to come up with the simplest rough state logic. The state of each gray rectangle represents an animation, and the arrow lines indicate the direction of state switching. For example, the standby and mobile can switch over to each other, but standby can switch to death, but can not be cut back to standby. The so-called people die can not stand by, that is the truth. Here is a small flaw, that is, my state machine is to demonstrate the convenience of the Chinese name, you'd better not use Chinese. Because...


Then take three combos as an example to tell a relatively complex state machine relationship. Normal order for Standby → attack 1→ attack 2→ attack 3→ attack 3 pick → Standby, this is a set of three even hit the order, but the player operation may only press the attack, then the order of the state machine is standby → attack 1→ attack 1 receive strokes → standby. Attack 2 likewise. This is a reasonable request from the Act or ARPG plan. A state will have two feeder states, at this time the state machine switching logic is in a primary school to understand the level of graduation, next we say a junior high school graduation.


Right-click in the state Machine window, create sub-state machine creates something called secondary state machines, well, we're not going to use that low chicken name, we'll call him grey Hexagon state machine.


The function of this state machine is that he can create another set of secondary states. For example, in the Act game, the character stands up to attack defense, while squatting is another set of attack defenses. Squat is secondary state, because squat run, squat attack These actions are based on squat this state, so they can become a secondary state machine independently.


Double-click the gray hexagon state machine to go to the secondary state machine editing page. The title bar can see the Squat tab below the base layer. Here is a simple list of several squat animation state for easy to understand. This is a comparison of the requirements of the high standards demanded by the master, such as squat attack defense, air attack defense, attack defense, poison, attacks, attacks, and other sub-states. Engong you graduated from Junior high School, completed nine years of compulsory education to become an ordinary animator


Now to the high school curriculum, you met an ideal planning dad, he made an unreasonable request to you. When the joystick gently pushes forward, the character moves slowly, the character runs quickly when pushing forward, and when the rocker is pushed around, the character's small amplitude turns, and the character turns sharply when it pushes around. Put down the dog, don't rush X it. can solve unreasonable requirements, this is the difference between you and the ordinary animators. You finish your high school graduation when someone else is on the dog day and the whole zoo.

Select "Move" this gray rectangular state machine Create a behavior tree with the new blendtree. Double-click into the Behavior Tree edit page


In order to meet this has the ideal planning dad, you need to do the following animation, standby, standby small turn, standby big turn, go, go small turn, go big turn, run, run small turn, run big turn. The animation of the turn can be done on one side only, and the other side is implemented with mirrored animations. These animations are then linked to the behavior tree. Properties panel, set the Behavior tree property to 2D Freedom Cartesian, here do not introduce a few behavior tree attribute tags, you can try it yourself, the other tags are on this basis to do subtraction is easy to understand.


Fill in the Motiom the animation, PosX, Posy set the coordinates, the clock icon indicates the speed, the villain icon indicates an animated image.

Here the coordinates set 0, 0 The origin is standby, straight up is walking, and then upward is running, the origin of the transverse position, the close distance is the small rotation of the painting, long distance is the large rotation of the painting, run is also so. The red dots in the graph indicate the status of the current role, because there are unlimited numbers between 0 and 1, so this state is infinite, he is a fusion of multiple states, can get up to four animation state at the same time and fused into a completely new intermediate state. To finish this step, you need the program master Help to map the amplitude of the rocker push to this plane, you can achieve the ideal of planning dad put forward the demand. By this, your high school graduation, is a great talent! But I know you're not that easy to meet, so let's take a little high school rocket accelerated course.


Just that has the ideal planning dad a pat on the forehead suddenly had a brilliant idea, when the character ran to the fastest state, he can explode gas, into the Fury state, but with the fury value decreased, to gradually change back to normal running. At this point, we are going to add a linear behavior tree under the running state machine. Yes, the child of the behavior tree can also be a behavior tree, and if your plan is Bian (TAI), the behavior tree can be a true "tree" with infinite branching.

Finally, to show you a more complex state machine, it contains a master state, five sub-states, n state machine, there is a behavior tree, well, high school rockets accelerated probably so ...


Koko, you don't think it's really over, I'm the kind of person who can only teach high school level, I'll give you some college! Why

Layer animations look nothing new basic each animation software will provide layer animation but Unity's layer animation is in the state machine here each additional layer can be configured a new set of state machine!

Finally ushered in the day ... You defeated the ideal of the planning of the father, since then invincible, vertical and horizontal game research and development industry invincible. I didn't expect him to show up.

Yes, that's him, he's called the layman's boss ...

He proposes a small achievable goal that you should give each animation a facial expression.


A running to have a sad sorrow fear all kinds of expressions, a standby also want to have emotions worry fear various expressions. You fight to say that resources are more than n times, he said we do is a boutique high-quality game, do not care about the amount of resources. You take a bite of the group, said the workload will double, he said if you do not say, he does not mind the substitution "is just art, everywhere recruit to AH." When your life is helpless, your old friend "Unity game animation from the introduction to hospitalization" is always spicy and strong behind you!

It's just an expression! Create a new animation layer! Build a state machine with an expression! Then do a set of emotions worry about the expression of fear! Attention! Just one set! and throw it to the program! Let him write the call logic! can be perfect to achieve every animation has a variety of expressions!

At this time the boss put forward a little idea, I heard that dress up very profitable, we also want to do dress up! and to each of the clothes for different movements have a corresponding animation! What the? You told me to add a facelift when the project was over the middle?

Ben, the baby stabbed you in the bucket.

Don't worry, we can! We just need to build a new layer of clothes, create a state machine corresponding to the body animation one by one, and then configure the animation of the clothes on the line! Well, this approach requires a huge amount of work and resources. But the project in the middle of the demand for replacement, this is almost the only solution!

So far, the boss has been very impressed with you! But when he drank last night, he thought of something again! "Our game has a variety of combat angels, some have two wings, some have eight wings, the most powerful battle Angel eldest brother has 16 wings, but their body animation is the same!" Young man you want to find a way to make them public body animation resources, and then everyone with their own wings animation! This is also to listen to your ideas to save resources. (Don't ask me why I'm not quitting because you're poor!) )

OK, how to do it! We're going to create a new state machine for each character, two tiers per state machine. One layer is the body animation, we have a common set of actions, one layer is the wing animation, we use their own separate action. Simple, it's that simple. Ha-ha hindering hindering ... What the hell have I been through to learn these ah!


Layers page, click on the right plus new layer


Click on the Gears of each layer to set the layer properties, from top to bottom respectively is the weight (this layer on the impact of the weight of the animation), Mask (body mask, used to cover all parts of the body animation such as animation needs to cover all the parts of the turn), mixed mode (optional overlay or overlay, literally)


Here is an additional introduction to an override controller. Just call him a plus. State machine Well, create it just like creating a normal state machine. It is equivalent to an original state machine with a shell outside, so that we can perfectly inherit all the original state machine configuration, and can therefore change, the original state machine to specify any location of the animation.

Unity animation Knowledge of the second: Animator Animation state machine

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.