Control of "Unity" 10.4-type human animated characters

Source: Internet
Author: User

Categories: Unity, C #, VS2015

Date Created: 2016-05-02 I. INTRODUCTION

Once you've imported character grids and animations and set up Avatar, you're ready to start using them in the game. The following sections cover the main features provided by Mecanim for controlling and sequencing animations. Second, cycle cartoon paragraph

One common operation for using animations is to ensure that animations loop correctly. For example, it is important to start with a similar gesture for the animated segment of The walking cycle (such as starting with the left foot on the ground and the right foot on the ground at the end) to ensure that no foot slippage or erratic erratic movements occur. Mecanim provides a handy tool for solving this problem, allowing animation segments to loop based on posture, rotation, and position.

1. Related attributes

(1) Start, end--begin and end

If you drag the start (start) or end point of the animation segment, you will see the loop (looping) fit curve for all parameters (based on parameters that can be cycled). If you place the starting (start), end (ending) marker in the green attribute curve, you increase the chance that the fragment will loop correctly.

(2) loop match--loops Matching

Loop matching indicator (loop match) is used to display the loop condition of the selected range.

Not green indicates that the match is inappropriate, and the result is that the animation may cause ghosting (also known as "Artifact") when playing.

(3) loop pose--cycle Posture

If the loop match indicator is all green, the looping posture (loop Pose) enabled is correct so that the pose loop does not appear "pseudo-shadow" when the animation plays.

2. Animation components (Animator Component)

Any game object with Avatar (Gameobject) has an animation component (ANIMAOR), which is a link between the role and its behavior.

The animation component refers to the animation controller (the Animator controller), which is used to set the behavior of the role. Includes settings for state machines, mixed-tree (blend trees), and events controlled by scripts.

The relevant properties are as follows:

    • Controller controllers. Animator Controller attached to this role
    • Avatar the Avatar of this role.
    • Apply root motion. The position of the role should be controlled from the animation itself or from the script.
    • Animate Physics to animate physics. That is: Should the animation interact with the physical?
    • The culling mode of culling mode animation
    • Always animate plays the animation at all times, without culling
    • Based on Renderers is based on the renderer's animation processing. That is, when the role renderer is not visible, only the root motion is animated, while the rest of the body remains static.

3, animation controller (Animator controllers)

You can view and set role behavior from the animator controller (Animator Controllers) View menu: Window > Animator Controller (Animator controllers).

The animation controller (Animator controllers) can be created from the Project View menu: Create > Paint controller (Animator controllers). This creates a. controller resource on disk that is displayed in the Project Explorer (Project Browser) with the following icon:

After the state machine is set up, you can place the controller on an animated component with any role in Avatar in the hierarchy view (Hierarchy view).

The Animation Controllers window (Animator controller windows) includes:

(1) Animation layer widget (Animation layer widget) (upper left corner, see animation layer?)

(2) event parameter widgets (Event Parameters widget) (lower left corner, see animation parameters?)

(3) Visualization of the state machine itself.

Note that the Animator Controller window (Animator controller Windows) always displays the state machine in the recently selected. Controller resource (regardless of the currently loaded scene). Third, animation state machine

It is common for a character to have several different animations that correspond to the different actions that it can perform in the game. For example, it may gently breathe or sway when idle, walk when ordered, and raise his arms in panic when the platform falls. Controlling the playback of these animations can be a very complex script task. Mecanim borrowed a computer science concept called a state machine to simplify the control and sequencing of character animations.

1. Basic principle of State machine

The basic idea is that the character is busy with some special actions at any given time. The available actions depend on the type of game, but typical actions include idle, walking, running, jumping, and so on. These actions are called States, and in the scene, the characters are walking, idle, etc. "state." Typically, a role is restricted to entering another condition, rather than being able to convert directly from any state to any other state. For example, running jumps can never be converted directly from an idle state to a run-hop state when the character is already running and not stagnant. The selection of roles that can enter the next state from the current state is called a state transition. In summary, state sets, transform sets, and variables that remember the current state form a state machine.

State machine states and transitions can be represented by a graphical representation where nodes represent states, arcs (arrows between nodes) represent transformations. You can think of the current state as a marker or a highlight on one node, and then simply jump to another node along one arrow.

The value of an animated state machine is that it can be easily designed and updated with relatively few encodings. Each state has a related action (motion) and plays when the machine is in that state. This allows the animator or designer to define the possible order of role actions and animations without worrying about how the code works.

2, Mecanim State machine

Mecanim's animated state machine (Animation-machines) provides a way to overview all the animated segments associated with a particular role, allowing various events in the game, such as user input, to trigger different animations.

You can set the animation state machine from the Animator Controller window (Animation, machines) as follows:

The state machines contains states (states), Transformations (transitions), and events, and smaller sub-state machines (sub-state machines) can be used as components in larger machines.

3. Animation status (Animation state)

The Animation state is the basic building block of an animated state machine (Animation). Each state contains a separate animation sequence (or blend tree) that will play when the role is in that state. When an event in the game triggers a state transition, the role is left in the new state, and the animated sequence of that state is then taken over by playback.

The relevant properties are as follows:

The default speed for Speed animation

Motion (motion) An animated segment assigned to this state

Whether foot ik (Foot ik) should consider "foot ik" (Foot ik) for this state

conversion (transitions) List of transitions originating from this state

The default state (shown in brown) is the state of the computer at the time of the first activation. If necessary, you can change the default state by right-clicking another state and choosing set as Default from the context menu. The Solo and mute (mute) check boxes on each transition control the animation preview behavior-see this page for more details.

You can add a new state by right-clicking the empty space in the Animator Controller window (Animator) and choosing Create State (created), empty from the context menu. Alternatively, you can drag an animation to the Animator Controller window (Animator. Controllers windows) to create the state that contains the animation. (Note that you can only drag the Mecanim animation to the controller-non-Mecanim animations are rejected.) The state can also contain a blend tree (blend trees).

Arbitrary states (any State)

Any state is a special state that always exists. This state exists for situations where you want to transition to a specific state, regardless of the state you are currently in. This is a quick way to add the same outward transition to all States in the machine. Note that the special meaning of any state means that it cannot be the end point of the transition (that is, jumping to "arbitrary state" cannot be used as a way to pick a random state for the next entry).

4. Animation conversion (Animation Transition)

The animation transform (Animation Transition) defines that only one transition is active from an animated state (Animation states) at any given time.

Related properties:

Atom (Atomic) is this conversion an atomic conversion? (cannot be interrupted)

The condition (Conditions) here determines the time when the conversion is triggered:

You can also use exit time, exit, without parameters, and specify a number that represents the normalized time of the source state (for example, 0.95 indicates that the conversion is triggered when 95% of the source fragment content is played).

Parameter values (if required): You can adjust the conversion between two animation segments by dragging the overlapping start and end values. Four, mixed trees (blend tree)

A common task in game animation is to mix two or more similar motions. The best known example might be a mix of walking and running animations based on character speed. Another example is when a character tilts to the left or right as it turns during a run.

It is important to differentiate between transformations (Transition) and mixed trees (blend tree). While both are used to create smooth animations, they are used for different types of situations.

Basic concepts:

Transform (Transition): Used to smooth transition from one animation state (Animation) to another within a given amount of time. The transform is specified as part of the animation state Machine (Animation). If the conversion is fast, it is usually possible to convert from one movement to a completely different motion.

Blend tree: Lets you blend multiple animations smoothly by combining parts of all the animations to varying degrees. The amount of each movement involved in forming the final effect is controlled using a mixed parameter, which is just one of the numeric animation parameters associated with the animator controller (Animator). To make the blended motion meaningful, the blended motion must have a similar nature and time. The blend tree is a special state type in the animator controller (Animator controllers).

Examples of similar movements can be various walking and running animations. To make the blend work well, the movement in the fragment must occur at the same normalized point in time. For example, walking and running animations can be aligned so that the moment the foot touches the ground occurs at the same normalized point in time (for example, the left foot is treading at 0.0, while the right foot is on the 0.5 tread). Because the normalized time is used, it does not matter whether the fragment has a different length.

To get started with the new blend tree, you need:

Right-click on an empty space on the Animation Controller window (Animator)

From the context menu that appears, choose Create state > New blend tree (from new blend trees).

Double-click the blend tree to enter the blend tree (blend graph).

The Animator Controller window now displays a graph of the entire blend tree, while the viewer (Inspector) displays the currently selected node and its immediate children.

The Animator window displays a graph of the entire blend tree. On the left is a blend tree containing only the root blend nodes (blend node). On the right is the blend tree containing the root blend node and the three animated segments (Animation Clip) as child nodes.

This provides a graphical visualization of the way the animation is combined when the value of the parameter changes (when you drag the slider, the arrows that originate from the root of the tree change its shading to show the main animation segments).

You can select any node in the blend tree diagram to view it in the viewer (Inspector). If the selected node is a cartoon segment (Animation clip), the Viewer (Inspector) for the animated segment (Animation clip) is displayed. If the animation is imported from a model, the settings are read-only. If the node is a mixed node (blend nodes), a blend node's viewer (Inspector) is displayed.

is the blend node (blend nodes) shown in the viewer (Inspector) that was added before the exercise.

The Blend Type drop-down menu is used to select one of the different blending types that can be blended according to one or two parameters. You can learn more about the different blend types and other blend tree options on the following pages.

1, one-dimensional mixing (1D Blending)

The first option in the Viewer (Inspector) for mixed node (blend nodes) is the blend type (blend types). This drop-down menu is used to select one of the different blending types that can be blended according to one or two parameters. One-dimensional blending (1D Blending) mixes sub-motions according to a single parameter.

After you set the blend type, the first action you need to take is to select the animation parameter (Animation Parameter) that will control the blend tree. In this example, the parameter is direction (direction), which is 1.0 (left) and +1.0 (right), where 0.0 means running straight without skewing.

You can then add individual animations by adding animation segments (Animation Clip) to the blend tree by clicking +, adding a motion field (add Motion field). When finished, it should resemble the following:

2, two-dimensional mixing (2D Blending)

The first option in the Viewer (Inspector) for mixed node (blend nodes) is the blend type (blend types). This drop-down menu is used to select one of the different blending types that can be blended according to one or two parameters. The two-dimensional hybrid (2D Blending) type mixes sub-motions according to two parameters.

3. Other Blend tree options

The following options are common for one-and two-dimensional blends.

Timescale (Time scale)

You can use the animated Speed Number field (the column with the clock icon at the top) to change the "natural" speed of the animation segment (Animation Clip), so that you can use the Value 2.0 as the speed to make the walking speed twice times the previous one. The Adjust time scale > Uniform velocity (homogeneous speed) button adjusts the speed of the clip so that they conform to the minimum and maximum values of the parameter, but maintain the same relative speed that was originally available.

Note that the Adjust time scale drop-down menu is available only when all motion is a cartoon segment (Animation Clip) instead of a sub-blend tree (blend tree).

Mirroring (mirroring)

You can mirror any Animation clip in the motion list by enabling the right-most mirror switch. This feature allows you to use the same animations in both original and mirrored versions without using memory and space two times.

Control of "Unity" 10.4-type human animated characters

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.