Skip to content

IAnimatorFacade

Mikhail Albershtein edited this page Mar 30, 2020 · 8 revisions

Animator Facade

Animator Facade is a class that is in charge of connecting the character with the animator. The animator should be on the same gameobject where the mesh is.
There are two interfaces that are being used:

  • IAnimatorFacade
  • ICharacterAnimator

Why do we have two? They look very similar

IAnimatorFacade ICharacterAnimator
IAnimatorFacade ICharacterAnimator

IAnamtorFacade can have logic, ICharacterAnimator only transfers parameters to the animator.

Example - landing animation

Let's have a look at how we set landing animation. First, we have to check if the current animation is unskippable or not. If it's not we can start the landing animation, if it is we shouldn't play it. Then, we are going to play the landing animation, we should say to the animator that we are not falling anymore. We can make all of this in one class, but I found it more convenient to divide the logic part and the "animator" part into two classes. We are going to communicate with an animator mainly through the IAnimatorFacade(there could be some exceptions but creating that kind of communication is highly recommended).

IAnimatorFacade ICharacterAnimator
isAboutToLand Falling