Unity animation - the use of Animation

1. Click Window > Animation on the top navigation bar of unity to open the Animation window

Through this window, you can create and edit animations, and you can also view imported animations. The Animation window can only view and edit animations in the same clip at the same time

2. Select the node in the Hierarchy panel, that is, the object to be animated. There is no animation on this object. You can click the Create button in the middle of the Animation window to create an animation Clip

After clicking to create a new animation clip, a file dialog box will pop up, where you can set the location to save the animation clip. (In order to keep the project file directory clean, do not save it in the project root directory, it is recommended to save it in the Animations folder)

After saving, an Animator component will be automatically attached to the original object without animation

After creating the animation clip, you can start to make animation.

The Animation window has two modes: recording mode and preview mode.

In recording mode, when you make changes to the object (such as moving, rotating, scaling, modifying properties, etc.), Unity will automatically generate keyframes at the current time position and record the modified properties.

In preview mode, modifying objects will not automatically create/modify keyframes. If you need to create/modify keyframes, you need to manually click the Add Keyframe button

The Animator component is a player used to control animation playback, switching between multiple animation clips, etc., for central control

The first attribute of the Animator component is Controller, and the file corresponding to the project directory is an Animator Controller type file, in which you can define how to switch between animation Clips. Double-clicking this file will open Unity's Animator window, showing the contents of the file. The Animator component will be discussed in detail later.

After clicking the record button, it enters the recording state.

You can modify the current time position by dragging on the time axis.

You can also modify the position of the time axis by modifying the number in the input box of the current frame number. By default, the frame rate of the animation is 60, which means it plays 60 frames per second. If the current frame number is set to 30, it will be at 0.5 seconds.

In recording mode, whether it is moving, rotating, or scaling objects in the scene, or modifying the properties of object components in the Inspector panel (properties supported by Unity animation), Unity will automatically add keyframes to the current time of the animation Clip to save.

After editing the animation, you can click the record button again to exit the recording mode to prevent subsequent operations on the object from being recorded in the animation.

Now you will see that in the Animation window, there are many properties on the left side. These properties are the list of all recorded properties. You can also manually add properties that need to be animated by clicking the Add Property button below.

If you are not in recording mode, modifications to the object will not be automatically recorded in the animation clip. If you need to record, you need to manually add keyframes for recording.

If the properties of the object are modified in the Inspector, the properties of the object will change from light blue background to light red, indicating that the property has been modified. At this time, you can right-click the corresponding attribute, click Add Key in the pop-up menu to add a key frame, and save the data of the attribute to the animation clip. If you have modified multiple properties in the current frame, you can click Key All Modified in the menu (record all modified properties as keyframes) or Key All Animated (record the values ​​of all properties in the property list, even if they are the same as the previous frame) properties will also be recorded) to save all modified properties at once

You can also click the Add Keyframe button on the left side of the Animation window to record the keyframe of the selected property in the current property list. If no property is currently selected, all properties will be recorded. As shown below

K Key All Animated, will record the keyframe of the selected property in the current property list, if no property is currently selected, all properties will be recorded.

Shift + K Key All Modified, record the values ​​of all modified properties in the animation property list as keyframes.

edit keyframe

When editing keyframes, you can select multiple times (the same applies to Curve editing):

  • Hold down Shift or Ctrl, and then click keyframes to select multiple keyframes
  • Multi-select keyframes by marquee selection
  • Hold down Shift or Ctrl while making a frame selection, you can add or remove frame-selected keyframes

Finally, preview the effect, click the button to view the effect

Guess you like

Origin blog.csdn.net/jiuzhouhi/article/details/131209448