What is keyframe animation in Unity? (2024)

Keyframe animation refers to a method of animation where specific frames, known as keyframes, are defined to represent different stages of an animation. Unity smoothly interpolates between these frames, creating the illusion of a change or movement.

Steps to create keyframe animation

Given below is a detailed guide on how to set up keyframe animation in Unity.

Select the GameObject

  • Create the GameObject of your choice.

Open animation window

Create new animation

  • Click on Create button to create a new animation.

  • It prompts you to choose the name and location of the file.

Note: In the latest versions of Unity, creating a new animation creates an animator controller as well so, there is no need to set up animator controller separately.

Add properties

  • Select the properties of the GameObject that you are interested in modifying, such as position, scale, or color.

Enable animation recording

  • Click on the red circle named Enable/Disable Animation Recording button.

    • It is used to define the keyframes for your animation.

    • It allows you to record any changes you make to your GameObject.

Set keyframes

Drag the timeline cursor to the time where you want to change the properties of the GameObject.

  • You can directly modify the properties of the GameObject from the scene view.

  • Unity will automatically record this as a keyframe.

Disable animation recording

  • Click on the red circle again to disable the keyframe animation once you are done setting the keyframes.

Create a C# script

  • Create a new C# script to trigger the animations.

A sample C# script is given below.

What is keyframe animation in Unity? (2024)
Top Articles
Latest Posts
Article information

Author: Allyn Kozey

Last Updated:

Views: 5938

Rating: 4.2 / 5 (43 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Allyn Kozey

Birthday: 1993-12-21

Address: Suite 454 40343 Larson Union, Port Melia, TX 16164

Phone: +2456904400762

Job: Investor Administrator

Hobby: Sketching, Puzzles, Pet, Mountaineering, Skydiving, Dowsing, Sports

Introduction: My name is Allyn Kozey, I am a outstanding, colorful, adventurous, encouraging, zealous, tender, helpful person who loves writing and wants to share my knowledge and understanding with you.