The relationship between Generic animation import settings and Root Motion in Unity3d

Source: Internet
Author: User
Tags in degrees

Unity3d's Mecanim animation system can directly reuse the displacement in animation files produced in 3DS MAX, which is achieved through applyrootmotion, and we only need to set Animator APS while using Animator to control animation playback The Plyrootmotion field is True to OK.

So how do we use this feature to achieve some of the effects we want? What exactly does this applyrootmotion mean?

Applyrootmotion, literally, is "applying the movement of the root node", which sounds like something. But we can see this passage from the official documentation:

The Root Transform is a projection on the Y plane of the Body Transform and are computed at runtime. At every frame, a change in the Root Transform is computed. This "is" then "applied to" Game Object to make it move.

The meaning of translation comes to this:

The motion transformation of the root node is actually a projection of the motion transformation of the whole object through the Y axis perpendicular to the horizontal plane. The motion transformation of the root node is calculated in every frame of the animation. The computed root node transform results are applied to the object that plays the animation, and the object is moved by the motion transform of the root node.

The general meaning of this passage is that the rootmotion is the displacement of the animated object on the X-and z-axes, and this displacement is calculated on the X and Z axes based on the displacement of each frame of the object in the animation that is actually being played.

This feature is very good especially for some skill animation, the whole animation is a certain displacement, but the animation is the displacement of the motion designer in the design according to the action needs to be transferred out, displacement is directly related to the amplitude of the action and matching.

Then when releasing the skill, only need to play the animation directly, and the application of the Root Motion features can be very good to complete the role in the play attack action while moving, after the action is finished in the animation end frame role in the position, switch to standby action is OK.

Looks like a good look, right? Yes, it's really cool. But there are a lot of things that we need to know in the future before we can make what we want.

Let's take a look at the topic and talk about this Animation Import Settings the settings in the "Animations" tab page.

  • Import Animation, this can be imported animation into Unity project;
  • Bake animations, this option is only available when using the humanoid animation and using the IK feature;
  • Anim.compression, this is about the animation compression option, the default is to select Keyframe Reduction this is "compression keyframe", that Unity will Self-resample animation keyframes, there are two options "Off and Optimal", One is to turn off animation compression, one is the most optimized compression (should be the highest compression efficiency, animation effect may also be higher distortion)
  • With the keyframe Reduction or Optimal compression option selected, there will be three factor configurations to control the compression options, Rotation error,position error and scale error, and this three parameter defaults to 0.5, the smaller the fine The higher the degree, the less distorted the animation.
  • Clips, which lists all the animations under this FBX file, we create and delete animation segments (Animation Clip) based on the default animation file, and of course each animation segment can specify the starting and ending frames; The following settings are for a single animated segment drop:
    • loop time, after checking this option, if the Animator is playing this animation state, after playing the first time this animated paragraph, Automatically loops back from the start frame again to play the animation, so it repeats itself. If we do not check this option, for example Animator has been playing this animation state, then the animation will be fixed at the end of the animation frame, until we switch the state of the Animator state machine through Animator, switch to other animations;
      • loop Pose and Cycle Offset, two options in effect after checking loop time, loop Pose for controlling animation loop playback, from When the beam frame is switched to the starting frame, the animation's action can be seamlessly bridged, cycly offset is used to control the loop when the start frame offset;
    • root Transform Rotation, rotation information of the root node
      • bake into Pose, the rotation information of each frame of the root node will be baked into the animation's skeletal motion, and the rotation information of the root node will not be in root during the whole animation. Motion acts on the gameobject of the animation, which means that the Rotation value in the object's Transform is not altered by any rotation of the object in the animation while the animation is playing, but rather it retains a constant value, Consistent with the rotation value before the animation is played;
      • based upon (at Start) or Based upon, the reference base of the root node rotation, with two options "Original and root node Rotation" These two respectively refers to the animation file specified in the rotation value and the root node rotation information, in fact, I would like to think of Original as the animation of the central point of rotation value, because throughout the process of animation, all bones will certainly have rotation and displacement of the transformation, but the original point of the animation is actually sure, This understanding feels simpler and more image, tick Bake into Pose, will become Based upon without checking Bake into Pose will remain as Based upon (at Start), this is still wood understanding why; /li>
      • offset, the rotation angle is offset from the reference datum (in degrees);
    • root Transform Position (y), root node displacement information (y-axis)
      • bake into Pose, tick to bake the motion information of each frame of the root node in the vertical Y-axis direction into the animation bone movement, during the whole animation play, All displacement information in the y-axis of the root node does not function through root Motion to the gameobject of the animation, which means that we see in the scene that the object has a displacement on the Y axis, such as moving up or down, but the Position in the object's Transform The information will not change and will be consistent with the Position information before the animation is played;
      • based upon or Based upon (at Start), this Looks a little different oh, after the selection of Bake into Pose will become Based upon (at Start), uncheck the time is Based upon, but this can be understood. If you do not bake, then the change in the Y axis of root motion depends on the y-axis shift of the selected "Original or Root Node Position", and if you choose to bake it, use the y-axis of the starting frame of the animation as the entire animation Root motion Y-axis displacement, the displacement of the y-axis is constant during the whole animation process;
      • offset, offset vertically;
      /li>
    • Root Transform Position (XZ), root node displacement information (horizontal, XZ axis)
      • Bake into Pose, the motion information of each frame of the root node in the horizontal plane (x and Z axis) is baked into the animated skeletal motion, and all the displacement information of the root node in the X and Z axes is not played by Root motion to the Gam that plays the animation during the whole animation. Eobject, this means that we see the object moving on the horizontal plane in the scene, but the Position information in the object's Transform will not change, consistent with the Position information before the animation, if the object moves forward 3 meters, We'll see that the object actually moves forward during the entire animation, and actually moves forward 3 meters to the last frame, but when the animation is finished, when you switch to any other animation, the object will flash back to the position of the object before the animation is played, So usually we need to keep the motion shift animation will not check this option. So this option is a horse with a pinch? For example, some of the standby animation, we actually want the object just to do a standby action, but actually do not want to let the object in the horizontal direction of displacement, this time you can check this option, then it looks like the object is nailed to the horizontal plane;
    • Mask, which is primarily used to control the movement of motion between the various bones during animation playback.
      • Definition, you can choose to create from an animated file or choose to use a configuration that has already been created in another animation file;
      • Transform, this is the hierarchy of all the bones in the animation file, you can choose to check those who need to apply motion transformation in the animation of the bones;
    • Curves, which is mainly used to set some animation-related parameters, such as controlling the speed of the entire animation process parameters and so on, in the process of animation can be played through the animator.getfloat (paramname) function to read the value of the curve, the X- The axis is an animated timeline, the Y axis is the value of the curve, the curve can be increased by the Curve editor key points, adjust the slope of the curve to edit, read by default according to the current animation playing progress as the value of the X-axis reading, a cartoon segment can have multiple curves;
    • Events, which are used to trigger events during an animation, such as jumping and landing two events throughout the animation that need to be triggered at an accurate point in time and notified to other objects in the game, you can add event notifications on the events timeline, set the trigger's method name and parameters, On the gameobject that plays the animation, make sure there is a script in the same way as the method signature of the event notification, and when the animation plays to the trigger notification time, the time notification will be broadcast to Gameobject, and the method signature method in the script will be recalled. Then we can do what we need to do.

Having said so many things that seem to be not very relevant to Root Motion, what is our topic today? It must still be Root Motion. Mainly because the animation import settings for the application of Root Motion is very direct, so the front ramble on the animation import settings are listed again.

Back to the Chase, Generic Animation application Root Motion has the following features:

  1. The Root Motion only acts on the gameobject on the X and Z axes, without affecting the displacements on the Y-axis. For example, now play an animation from the ground forward somersault, set Animator applyrootmotion to True, that is, the application of Root motion, then the animation during playback, The object will be in the horizontal and vertical direction in accordance with the actual animation of the motion trajectory, if the applyrootmotion set to False, then we can only see the animation in situ jump and then landing, the animation should have in the horizontal direction of the displacement is not;
  2. Root motion is directly related to setting root Transform Position (XZ) When importing animations, and if we choose to bake the displacement of the root node in the X and Z axes to the animated bone movement, then the animation plays whether or not we will Animator the Applyrootmotion is set to True or False, the movement of objects on X and Z during animation plays is certain, as this has been baked into the skeletal animation, as long as the animation plays, the object will move, but in the process of animation play Gameobject Positi The on value does not change, and when we switch to another animation after the end of the animation, the position of the gameobject when the other animation starts playing will go back to where it was before the animation was played, so if we need to apply Root motion to an animation, So this animation does not bake its root Transform Position in the X and Z axes as it is imported, allowing Unity to calculate the location information of gameobject based on the displacement of the root node in the animation;
  3. Note the relationship between Root motion and the Rigidbody.velocity property, if you have two animations A and B, when you play a animation, you want the a animation to apply root motion, and when you play the B animation, you do not want to apply root motion, then straight When switching to animation B, set the Animator applyrootmotion to False to OK. However, if the gameobject of the animated animation has a rigidbody component, it is important to note that the velocity rigidbody when the A animation is played does not clear when switching to the B animation, that is, if the a animation is moving faster, then switch to the B animation , if you want the B animation to play when the gameobject in accordance with their own set trajectory movement, you need to manually switch to the B animation before the Rigidbody Velocity property to zero, to prevent gameobject in accordance with the motion inertia of A animation continue to move. This problem does not exist on the gameobject without the rigidbody component;

Here again, talk about the relationship between this animation and Rigidbody:

    1. If we do not bake the Root Transform Position Y and XZ axes, then in the course of the animation, Rigidbody will automatically get the speed information of the object motion in the animation, directly through the Rigidbody.velocity property can be obtained ;
    2. If we bake the y-axis, then the value of rigidbody.velocity on the y-axis will always be 0, the same for the XZ axis, and if the displacement of the XZ axis is baked, the value of rigidbody.velocity on the X and Z axes during the entire animation playback will be 0;
    3. If the animated object does not have a rigidbody component, then the motion of the animation will only be played by frame by the actual displacement of the animation, and there will be no motion inertia problem after the animation playback switch mentioned above, because the physics engine relies on the Rigidbody component, and if there is no such component, All animation playback is just a frame-by-frames animation, there is no concept of speed only move displacement.
    4. Rigidbody use of gravity has no effect on the motion of the animation on the y-axis, regardless of whether the Root Transform Position y-axis is baked.

Transferred from: http://7dot9.com/?p=528

The relationship between Generic animation import settings and Root Motion in Unity3d

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.