Animation

JunDev·2025년 3월 12일

Unity

목록 보기
8/8

In Unity, Animation and Animator are used to bring objects to life by making them move, change states, or transition between different poses.

Animation

Animation in Unity refers to creating movement or visual changes in GameObjects over time. This can include:

  • Moving objects (e.g., a door opening)
  • Changing properties (e.g., color fading)
  • Character movements (e.g., running, jumping)
  • UI effects (e.g., button hover effects)

Unity uses an Animation Clip to define how a GameObject should change over time.

Animator

The Animator is the system that controls and plays animations in Unity. It consists of:

  • Animator Component (added to a GameObject to play animations)
  • Animator Controller (manages animation states and transitions)
  • Animation Clips (the actual animations)

The Animator Component acts as the brain of animations and executes logic based on conditions.


Playing Animation on Code

Animator animator;

void Start()
{
    animator = GetComponent<Animator>();
}

void Update()
{
    if (Input.GetKeyDown(KeyCode.Space))
    {
        animator.SetTrigger("Jump");  // Play the jump animation
    }
}
profile
Jun's Dev Journey

0개의 댓글