Unity Mecanim animation system

  

1. Animator component

  • Controller: The Animator Controller file used.
  • Avatar: The skeleton file used.
  • Apply Root Motion: Whether the position of the GameObject bound to this component can be changed by animation (if there is an animation that changes the displacement).
  • Update Mode: Update mode: Normal means to use Update to update, Animate Physics means to use FixUpdate to update (generally used when interacting with objects), Unscale Time means to ignore timeScale to update (usually used in UI animation).
  • Culling Mode: Culling mode: Always Animate means to update the animation playback even if the camera is invisible, Cull Update Transform means to stop the animation playback when the camera is invisible but the position will continue to update, Cull Completely means to stop all updates of the animation when the camera is invisible .

 

 2. Create AnimatorController

   There are three initial states by default:

  • Entry: Indicates the entry when entering the current state machine, the state connected to this state will become the first state after entering the state machine;
  • Any State: Represents any state, and its role is that the state it points to is a state that can be switched at any time;
  • Exit: means to exit the current state machine, if any state points to the exit, it means that the current state machine can be exited from the specified state;

 

 3. Create a new state

   Right click -> Create State -> Empty.

  You can set this state as the default state, right-click -> Set as Layer Default State.

 

 4. State switching

   Right click -> Make Transition.

  State transitions can be performed by changing parameters.

 

  • Float: parameter of float type, which is mostly used to control floating-point parameters inside the state machine;
  • Int: parameter of int type, mostly used to control the integer parameter inside the state machine;
  • Bool: bool type parameter, mostly used for state switching;
  • Trigger: It is also a bool type parameter in essence, but its value is false by default, and after setting it to true, the system will automatically restore it to false;

   Has Exit Time: 

   

  If we check this option, when the animation transitions, it will wait for the current animation to finish playing before transitioning to the next animation. If the current animation is a cyclic animation, it will wait for the transition when the current playback is complete, so when the animation needs to be transitioned immediately Remember to uncheck it.

  In another case, when my current animation finishes playing, it will automatically switch to the next state pointed to by the arrow (no other jump conditions). At this time, this option must be checked, otherwise it will be stuck in the animation after the animation finishes playing. The last frame, if it is a looping animation, will keep looping.

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324439979&siteId=291194637