Skip to content

Animation tips

Nate River edited this page Jan 3, 2021 · 20 revisions

How to play animations from code?

If you're a beginner in Unity, just refer to CharacterAnimation.cs for code examples. Otherwise, jump to the next section.

How to edit and create new animations?

We make all our animations with built-in Unity animation system. You can edit them and create your own, it's not so difficult as you may think.

  • You can find all animations in HeroEditor/Common/Animation folder
  • Human.controller contains all animation states and transitions, you can open it with Animator window
  • Use Animation window to edit and create animations and transitions

Character animation has 2 layers: Upper and Lower. This allows us to play different combinations for upper and lower body animation. For example, we can play Slash while walking or Jab while running. You can see the full list of layers in Layers section of Animator window.

Most of animations have transitions from Any State. This means that they can be played at any time when certain conditions are met. You can select transitions and see their conditions. Conditions use Parameters, so you can see the full list of parameters in Parameters section of Animator window.

In this way, you can play animations from code by setting animation Parameters like this: Animator.SetBool("Ready", true);.