The relationship between animation components
Let's look at a picture:
Here we can see that the animator component we are binding on Gameobject is the control model for animation playback.
and its property controller corresponding to a animator controller file, the file can be opened in the animator window, which is designed as a state machine form of the system, the switching relationship between multiple states can be set in this interface.
Each state in the Animator controller corresponds to a animation clip, and each animation clip is a simple animation unit that can be opened in the animation window.
Animation file Animation Clip
If the FBX contains an animation file, you can create multiple animated clips within it, each animation clip containing a simple animation such as idle, run, and so on.
Animation file
An old animated form of a file that uses XML data to record animation information.
Use of Animation view
Well, back to our protagonist animation view, for the animation clip file, although you can use the Animation window to open the editor, but we generally do not edit, because it is too complex, this part should be in the modeling software by the Fine arts editor.
So what can the animation window be used for? The answer is that we can use it to make some simple animations, such as in some games, before the battle begins, the camera moves back and forth through the scene and back to the character (the goal is to let the player know the location of the enemy and the terrain of the battle scene before the battle).
Example of moving a camera
1. First we open the Animation window, select the main Camera in the scene, then click the Create button in the animation window to save our files, unity will generate two files, one animator Controller file and a animation file.
2. Below we click Add Property two times, add position and rotation, as follows:
3. Move the red line to the last frame, and then click Align with View on the menu bar Gameobject to move the camera to the location of the current scene view and rotate it toward the orientation of the scene view.
4. Click the Play button to see the camera move effect.
5. If you want to continue adding, you can add keyframes later by double-clicking the timeline.
At this point we will find that the main camera has been added a animator component, and all the parameters have been set up, we can directly click on the game to see the effect.
Apply Root Motion
In our animator component, there is an option to apply Root motion, and when unchecked, our animations move in world coordinates, that is, the values on our animation are set directly above the position of the target, and if checked, is to add the value of our animation setting above the position of the target.
Event System
For an animation, we can also add an event for any of its frames:
1. First, we add a component that receives event events for the main camera:
1 usingUnityengine;2 usingSystem.Collections;3 4 Public classTestanimevent:monobehaviour5 {6 Public voidShowanimmsg (stringmsg)7 {8 print (msg);9 }Ten}
2. Next we add an event at any frame in the animation window and call the Showanimmsg method to pass a string:
3. Run the game and you will see the output.
So what can we do with the function of the event? Imagine that if we wanted our characters to play a sound when jumping and landing, we could use the function of the event.
Unity3d's Mecanim Animation system learning Note (iii): Animation View