Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Animate Your Character | Unity Animation System
Fighting Game in Unity
course content

Course Content

Fighting Game in Unity

Fighting Game in Unity

1. Unity Animation System
2. Player Behavior
3. Enemy Behavior
4. Improve the Game
5. Improve the Flappy Bird Game

book
Animate Your Character

Sprite Animation

After adding a sprite animation in Unity, we should first define its mode as multiple.

We can also define the animation's bounds with the Sprite Editor.

The "Slice" option in the sprite editor allows you to automatically or manually define the boundaries of each individual sprite within the sprite sheet. After that, we can copy and paste all of the sprites of a certain sprite sheet into the animation clip. This method, called sprite animation, involves displaying a sequence of images (sprites) to create motion. You organize these sprites into an animation clip, defining keyframes and playback speed. Unity's Animation window enables precise control over timing and transitions between animations, bringing characters and objects to life.

How Sprites Animations Work

Animation Transition:

  • In a sprite animation, each individual image is called a frame;
  • The Sprite Renderer component in Unity is responsible for displaying sprites on a GameObject in the scene;
  • Unity automatically switches between frames at the specified intervals, creating the illusion of motion;
  • Behind the scenes, Unity is changing the sprite displayed by the Sprite Renderer component frame by frame, according to the animation clip you created;
  • Each frame of the animation corresponds to one of the sprite images you imported.

Animation Transition:

Animation Transition: The transition between two animations is depicted by the arrow from "attack" to "run". This indicates that when the "attack" animation finishes, it smoothly transitions to the "run" animation.

Transition Duration: The blue bar represents the duration of the transition. It shows how long it takes for the transition from "attack" to "run" to complete. In this case, it's about 0.14 seconds.

Has Exit Time: This checkbox, when enabled, means that the transition occurs when the "attack" animation reaches a specific point, which is set by the "Exit Time" parameter. In this screenshot, "Has Exit Time" is checked, meaning the transition starts when the "attack" animation is about 78% complete.

Conditions: Below the transition settings, you see conditions that trigger the transition. For example, "isRunning" being true means that the transition from "attack" to "run" happens when the character is running.

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 3
We're sorry to hear that something went wrong. What happened?
some-alt