In Unity, Animation and Animator are used to bring objects to life by making them move, change states, or transition between different poses.
Animation in Unity refers to creating movement or visual changes in GameObjects over time. This can include:
Unity uses an Animation Clip to define how a GameObject should change over time.
The Animator is the system that controls and plays animations in Unity. It consists of:
The Animator Component acts as the brain of animations and executes logic based on conditions.
Animator animator;
void Start()
{
animator = GetComponent<Animator>();
}
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
animator.SetTrigger("Jump"); // Play the jump animation
}
}