PO/Library/PackageCache/com.unity.2d.animation@5.0.7/Documentation~/FFanimation.md

1.7 KiB
Raw Blame History

Frame-by-frame animation

By using Sprite Swap, you can create frame-by-frame style animations by swapping to different Sprites on each frame at runtime. This is useful for simple animations, such as to show a character blinking. It is recommended that you first change the keyframe tangent before continuing with the workflow below:

  1. In your character Prefabs Sprite Library Asset (which can be automatically or manually created), add a new Category. Add the Sprite for each frame of your animation to this Category, and give them each a unique Label name.

  2. Select your character Prefab and drag it into the Scene view.

  3. Open the Animation window, and select your character Prefab. Then select the Add Property button, and select the Sprite Resolver components Label property.

  4. Change the Label property at each keyframe in the Animation window in the order they should appear for your animation. This simulates a frame-by-frame animation style.

Change the Keyframe Tangent

When animating with the Category and Label value of the Sprite Resolver in the Animation window, it is important to change the keyframes tangent in the Animation window to Constant.

This is because the Sprite Resolver component uses the defined string hash value to locate the desired Sprite. If the values between keyframes are interpolated, the Sprite Resolver will not be able to resolve and render the correct Sprite.